C# Char GetUnicodeCategory() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Char

Definition

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.

Syntax

Pass a char and compare the returned enum.

C#
UnicodeCategory cat = Char.GetUnicodeCategory('A');
CallWhat it does
Char.GetUnicodeCategory(c)Returns the UnicodeCategory for c.
Char.GetUnicodeCategory(s, i)Category of s[i].

Add using System.Globalization; for the enum name.

Library declarations
C#
public static UnicodeCategory GetUnicodeCategory(char c);
public static UnicodeCategory GetUnicodeCategory(string s, int index);

Parameters

ParameterDescription
cCharacter to classify.
s, indexOptional string index overload.

Return Value

Return ValueDescription
UnicodeCategoryDetailed category enum value.

C# Examples

Example 1 — Uppercase Letter

Print the category of A.

C#
using System;
using System.Globalization;

class Program {
    static void Main() {
        UnicodeCategory cat = Char.GetUnicodeCategory('A');
        Console.WriteLine(cat);
        Console.WriteLine(cat == UnicodeCategory.UppercaseLetter);
    }
}

How It Works

  1. Import Globalization. UnicodeCategory lives there.
  2. UppercaseLetter. A maps to that enum value.
  3. Equality check. Compare against the named constant.
  4. 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'));
    }
}

How It Works

  1. DecimalDigitNumber. Digits report this category.
  2. IsDigit agrees. The helper matches that idea.
  3. Two views. Enum for detail, boolean for quick tests.
  4. 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(' '));
    }
}

How It Works

  1. SpaceSeparator. Exact enum for ' '.
  2. IsSeparator true. Matches the separator helper.
  3. Tab differs. Tab would not be SpaceSeparator.
  4. 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.
Yes via the index overload.
Yes.

Next: IsAscii()

Return true when the character is in the ASCII range (0–127). .NET 7+ with System.Char.

IsAscii() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful