[英]Comparison Error While Converting C# to VB.NET
I am in the process of converting some c# code to that of VB.NET...I am running into error at the following 我正在将某些C#代码转换为VB.NET的代码...在以下情况下遇到错误
C# C#
if (bytes[i - 1] == ' ')
{
returnValue.Append("=20");
}
else if (bytes[i - 1] == '\t')
{
returnValue.Append("=09");
}
VB.NET VB.NET
If bytes(i - 1) = " "C Then <==error Operator "=" is not defined for types 'Byte' and 'Char'
returnValue.Append("=20")
ElseIf bytes(i - 1) = ControlChars.Tab Then <==error Operator "=" is not defined for types 'Byte' and 'Char'
returnValue.Append("=09")
End If
I believe the actual problems lies with the initial comparison. 我相信实际的问题在于最初的比较。 You are trying to compare a
byte
to a char
. 您正在尝试将一个
byte
与一个char
比较。 Try converting the byte
to a char
first. 尝试先将
byte
转换为char
。
if char(bytes(i - 1)) = " "C Then
Just try using 只需尝试使用
Convert.ToChar(bytes(i - 1)) = " "C
or 要么
bytes(i - 1) = Convert.ToByte(" "C)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.