在土耳其语区域设置中,以下似乎是一个问题:
Public Enum enFonts
TOKEN_Line_Number = 2
End Enum
Dim StyleName As String = [Enum].GetName(GetType(enFontsUpper), fnt).ToUpper
StyleName设置为" TOKEN_LxNE_NUMBER"其中x设置为大写I,顶部为点。为什么?
以下是演示此行为的测试代码:
乔金德
Module Module1
Public Enum enFonts
TOKEN_Plain_Text = 1
TOKEN_Line_Number = 2
End Enum
Public Enum enFontsUpper
TOKEN_PlaIn_Text = 1
TOKEN_LIne_Number = 2
End Enum
Friend Styles As New Collection
Sub Main()
Dim STL As String = "TOKEN_LINE_NUMBER"
Dim fnt As enFonts = enFonts.TOKEN_Line_Number
'The following compare fails
Call Compare(STL, enFonts.TOKEN_Line_Number)
' The following compare works because In changed i to uppercase I in LIne
Call Compare2(STL, enFontsUpper.TOKEN_LIne_Number)
End Sub
Private Sub Compare(STL As String, fnt As enFonts)
Dim StyleName As String = [Enum].GetName(GetType(enFonts), fnt).ToUpper
If StyleName.Equals(STL) Then
Call MsgBox(String.Format("'{0}' is equal to '{1}'", STL, StyleName))
Else
Call MsgBox(String.Format("'{0}' is NOT equal to '{1}'", STL, StyleName))
End If
End Sub
Private Sub Compare2(STL As String, fnt As enFontsUpper)
Dim StyleName As String = [Enum].GetName(GetType(enFontsUpper), fnt).ToUpper
If StyleName.Equals(STL) Then
Call MsgBox(String.Format("'{0}' is equal to '{1}'", STL, StyleName))
Else
Call MsgBox(String.Format("'{0}' is NOT equal to '{1}'", STL, StyleName))
End If
End Sub
End Module
答案 0 :(得分:0)
我现在发现问题出在土耳其语语言环境中的ToUpper
。 "i".ToUpper
返回大写字母I的顶部。 Stackoverflow中似乎有很多解决方案可以解决这个问题。简单的解决方案是使用ToLower
而不是`ToUpper。