Categorizes the character at the specified position in a specified string into a group identified by one of the System.Globalization.UnicodeCategory values.
- s
- A string.
- index
- The character position in s.
A System.Globalization.UnicodeCategory enumerated constant that identifies the group that contains the character at position index in s.
Type Reason ArgumentNullException s is a null reference. ArgumentOutOfRangeException The value of index is less than zero, or greater than or equal to the length of s.
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).