Char.GetUnicodeCategory Method (Char)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Categorizes a specified Unicode character into a group identified by one of the UnicodeCategory values.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- c
- Type: System.Char
A Unicode character.
Return Value
Type: System.Globalization.UnicodeCategoryA UnicodeCategory value that identifies the group that contains c.
The GetUnicodeCategory method does not always return the same UnicodeCategory value as the CharUnicodeInfo.GetUnicodeCategory(Char) method when passed a particular character as a parameter. The CharUnicodeInfo.GetUnicodeCategory(Char) method is designed to reflect the current version of the Unicode standard. In contrast, although the GetUnicodeCategory method usually reflects the current version of the Unicode standard, it may return a character's category based on a previous version of the standard or it may return a category that differs from the current standard in order to preserve backward compatibility. As a result, we recommend that you use the CharUnicodeInfo.GetUnicodeCategory(Char) method instead of Char.GetUnicodeCategory(Char).
The following example demonstrates GetUnicodeCategory.
Module Example Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) Dim ch2 As Char ch2 = "2"c Dim str As String str = "Upper Case" outputBlock.Text &= Char.GetUnicodeCategory("a"c) & vbCrLf outputBlock.Text &= Char.GetUnicodeCategory(ch2) & vbCrLf outputBlock.Text &= Char.GetUnicodeCategory(str, 6) & vbCrLf End Sub End Module ' The example displays the following output: ' LowercaseLetter ' DecimalDigitNumber ' UppercaseLetter