System.Char.GetUnicodeCategory Method

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

Syntax

public static System.Globalization.UnicodeCategory GetUnicodeCategory (string s, int index)

Parameters

s
A string.
index
The character position in s.

Returns

A System.Globalization.UnicodeCategory enumerated constant that identifies the group that contains the character at position index in s.

Exceptions

TypeReason
ArgumentNullException s is a null reference.
ArgumentOutOfRangeExceptionThe value of index is less than zero, or greater than or equal to the length of s.

Remarks

Character positions in a string are indexed starting from zero.

The char.GetUnicodeCategory(string, int) method does not always return the same System.Globalization.UnicodeCategory value as the System.Globalization.CharUnicodeInfo.GetUnicodeCategory(string, int) method when it is passed a particular character as a parameter. The System.Globalization.CharUnicodeInfo.GetUnicodeCategory(string, int) method is designed to reflect the current version of the Unicode standard. In contrast, although the char.GetUnicodeCategory(string, int) 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 System.Globalization.CharUnicodeInfo.GetUnicodeCategory(char) method instead of char.GetUnicodeCategory(string, int).

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0