为什么字符串案例比较突然停止在vb.net中工作?

时间:2015-05-25 11:00:48

标签: vb.net string tolower

有谁知道以下可能如何?使用.ToLowerLcase的所有突然字符串比较都停止了工作。

如果我在即时窗口中这样做:

?lcase(text)
"menu"
?lcase(text)="menu"
False

这只是几分钟前开始的。我正在使用:

  • .NET 4.5.2
  • Visual Studio 2013 Ultimate
  • Visual Basic

编辑: 此问题的根源来自:Please how can i return decoded bytes instead of text from a CryptoStream

更改代码后。

2 个答案:

答案 0 :(得分:4)

首先,我会停止使用LCase,因为它是VB 6兼容性代码。

其次我不会在字符串比较中使用"string".ToLower()"string".ToUpper()中的.NET构建,因为这会导致一些本地人出现意外结果。

更好地使用text.Equals("menu", StringComparison.OrdinalIgnoreCase)

我不知道问题的根本原因是什么,但希望有所帮助。

答案 1 :(得分:0)

查看String.Compare

'Declaration
Public Shared Function Compare ( _
    strA As String, _
    strB As String, _
    ignoreCase As Boolean _
) As Integer

结果小于零= strA小于strB 结果零= strA等于strB 结果大于零= strA大于strB。