Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Char.GetUnicodeCategory Method

Categorizes a Unicode character into a group identified by one of the UnicodeCategory values.

Overload List

Categorizes a specified Unicode character into a group identified by one of the UnicodeCategory values.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function GetUnicodeCategory(Char) As UnicodeCategory
[C#] public static UnicodeCategory GetUnicodeCategory(char);
[C++] public: static UnicodeCategory GetUnicodeCategory(__wchar_t);
[JScript] public static function GetUnicodeCategory(Char) : UnicodeCategory;

Categorizes the character at the specified position in a specified string into a group identified by one of the UnicodeCategory values.

[Visual Basic] Overloads Public Shared Function GetUnicodeCategory(String, Integer) As UnicodeCategory
[C#] public static UnicodeCategory GetUnicodeCategory(string, int);
[C++] public: static UnicodeCategory GetUnicodeCategory(String*, int);
[JScript] public static function GetUnicodeCategory(String, int) : UnicodeCategory;

Example

[Visual Basic, C#, C++] The following sample demonstrates GetUnicodeCategory.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of GetUnicodeCategory. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Imports System

Module GetUnicodeCategorySample

    Sub Main()

        Dim ch2 As Char
        ch2 = "2"c
        Dim str As String
        str = "Upper Case"

        Console.WriteLine(Char.GetUnicodeCategory("a"c))    ' Output: "1" (LowercaseLetter)
        Console.WriteLine(Char.GetUnicodeCategory(ch2))     ' Output: "8" (DecimalDigitNumber)
        Console.WriteLine(Char.GetUnicodeCategory(str, 6))  ' Output: "0" (UppercaseLetter)

    End Sub

End Module

[C#] 
using System;

public class GetUnicodeCategorySample {
    public static void Main() {
        char ch2 = '2';
        string str = "Upper Case";

        Console.WriteLine(Char.GetUnicodeCategory('a'));        // Output: "LowercaseLetter"
        Console.WriteLine(Char.GetUnicodeCategory(ch2));        // Output: "DecimalDigitNumber"
        Console.WriteLine(Char.GetUnicodeCategory(str, 6));        // Output: "UppercaseLetter"
    }
}

[C++] 
#using <mscorlib.dll>

using namespace System;

int main() {
   char ch2 = '2';
   String* str = S"Upper Case";

   Console::WriteLine(__box(Char::GetUnicodeCategory('a'))->ToString());        // Output: S"LowercaseLetter"
   Console::WriteLine(__box(Char::GetUnicodeCategory(ch2))->ToString());        // Output: S"DecimalDigitNumber"
   Console::WriteLine(__box(Char::GetUnicodeCategory(str, 6))->ToString());        // Output: S"UppercaseLetter"
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Char Structure | Char Members | System Namespace

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft