In C#, Char.GetUnicodeCategory returns a UnicodeCategory value that describes the character in fine detail—uppercase letter, decimal digit, space separator, and many more.
The Is* helpers are shortcuts for common categories. Use GetUnicodeCategory when you need the exact enum.
This is a static member of System.Char. You call it with the type name, such as Char.GetUnicodeCategory(...) or char.GetUnicodeCategory(...). A char holds one 16-bit UTF-16 code unit.
Equality check. Compare against the named constant.
More detail. Finer than a plain IsUpper boolean when you need it.
Example 2 — Decimal Digit Number
Show the category for 7.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
Console.WriteLine(Char.GetUnicodeCategory('7'));
Console.WriteLine(Char.IsDigit('7'));
}
}
Output
DecimalDigitNumber
True
How It Works
DecimalDigitNumber. Digits report this category.
IsDigit agrees. The helper matches that idea.
Two views. Enum for detail, boolean for quick tests.
Same character. Both APIs look at 7.
Example 3 — Space Separator
Classify an ordinary space.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
Console.WriteLine(Char.GetUnicodeCategory(' '));
Console.WriteLine(Char.IsSeparator(' '));
}
}
Output
SpaceSeparator
True
How It Works
SpaceSeparator. Exact enum for ' '.
IsSeparator true. Matches the separator helper.
Tab differs. Tab would not be SpaceSeparator.
Precise labeling. Useful in debugging classifiers.
Frequently Asked Questions
System.Globalization.
IsLetter covers several letter categories; GetUnicodeCategory names the exact one.
When you need the detailed enum instead of a yes/no helper.