如何在 C# 中使用 vbKeySpace?
How to use vbKeySpace in C#?
我正在我的 MVC 项目业务对象中使用一个 VB 函数 Class。
VB、
中的示例代码
intUBound = Len(astrInValue);
For intLoop = 1 To intUBound
strChar = Mid$(astrInValue, intLoop, 1)
intCharASCII = Asc(strChar)
If intCharASCII = vbKeySpace Then
strEncodedStr = strEncodedStr & "+"
Else
strEncodedStr = strEncodedStr & strChar
End If
Next intLoop
C# 代码如
intUBound = Strings.Len(astrInValue);
for (intLoop = 1; intLoop==intUBound; intLoop+=1)
{
strChar = Strings.Mid(astrInValue, intLoop, 1);
intCharASCII = Strings.Asc(strChar);
if(intCharASCII == vbKeySpace)
{
strEncodedStr = strEncodedStr + "+";
}
else
{
strEncodedStr = strEncodedStr + strChar;
}
}
这里,如何在C#中使用vbKeySpace?
vbKeySpace 只是一个常量整数值,您可以键入 32 而不是 vbKeySpace。
if(intCharASCII == 32)
{
strEncodedStr = strEncodedStr + "+";
}
但如评论中所述,建议避免像这样翻译遗留代码。
来源:https://msdn.microsoft.com/en-us/library/aa243025%28v=vs.60%29.aspx
我正在我的 MVC 项目业务对象中使用一个 VB 函数 Class。
VB、
中的示例代码intUBound = Len(astrInValue);
For intLoop = 1 To intUBound
strChar = Mid$(astrInValue, intLoop, 1)
intCharASCII = Asc(strChar)
If intCharASCII = vbKeySpace Then
strEncodedStr = strEncodedStr & "+"
Else
strEncodedStr = strEncodedStr & strChar
End If
Next intLoop
C# 代码如
intUBound = Strings.Len(astrInValue);
for (intLoop = 1; intLoop==intUBound; intLoop+=1)
{
strChar = Strings.Mid(astrInValue, intLoop, 1);
intCharASCII = Strings.Asc(strChar);
if(intCharASCII == vbKeySpace)
{
strEncodedStr = strEncodedStr + "+";
}
else
{
strEncodedStr = strEncodedStr + strChar;
}
}
这里,如何在C#中使用vbKeySpace?
vbKeySpace 只是一个常量整数值,您可以键入 32 而不是 vbKeySpace。
if(intCharASCII == 32)
{
strEncodedStr = strEncodedStr + "+";
}
但如评论中所述,建议避免像这样翻译遗留代码。
来源:https://msdn.microsoft.com/en-us/library/aa243025%28v=vs.60%29.aspx