Windows apps
Collapse the table of content
Expand the table of content
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 (Char)

 

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

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public static UnicodeCategory GetUnicodeCategory(
	char c
)

Parameters

c
Type: System.Char

The Unicode character to categorize.

Return Value

Type: System.Globalization.UnicodeCategory

A UnicodeCategory value that identifies the group that contains c.

The Char.GetUnicodeCategorymethod does not always return the same UnicodeCategory value as the CharUnicodeInfo.GetUnicodeCategory(Char) method when it is 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 Char.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).

Starting with the .NET Framework 4.6.2, Unicode characters are classified based on The Unix Standard, Version 8.0.0. In versions of the .NET Framework from the .NET Framework 4 to the .NET Framework 4.6.1, they are classified based on The Unix Standard, Version 6.3.0.

The following code example demonstrates GetUnicodeCategory.

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"
	}
}

.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show:
© 2016 Microsoft