VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-char-getunicodecategorystring-int32-method-with-examples/

⇱ C# | Char.GetUnicodeCategory(String, Int32) Method with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Char.GetUnicodeCategory(String, Int32) Method with Examples

Last Updated : 11 Jul, 2025

This method is used to categorizes the character at the specified position in a specified string into a group identified by one of the UnicodeCategory values. 

Syntax:

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

Parameters:

  • s: It is the String.
  • index: It is the character position in s.

Return Value: This method returns a UnicodeCategory enumerated constant that identifies the group that contains the character at position index in s

Exceptions:

  • ArgumentNullException: If the s is null.
  • ArgumentOutOfRangeException: If the index is less than zero or greater than the last position in s.

Below programs illustrate the use of Char.GetUnicodeCategory(String, Int32) Method: 

Example 1: 

Output:
the letter present at index 3 is DecimalDigitNumber 
the letter present at index 0 is UppercaseLetter 
the letter present at index 2 is LowercaseLetter

Example 2: For ArgumentNullException 

Output:
the letter present at index 3 is DecimalDigitNumber 
the letter present at index 0 is UppercaseLetter 
the letter present at index 2 is LowercaseLetter 

s is null
Exception Thrown: System.ArgumentNullException

Example 3: For ArgumentOutOfRangeException 

Output:
the letter present at index 3 is DecimalDigitNumber 
the letter present at index 0 is UppercaseLetter 
the letter present at index 2 is LowercaseLetter 

index is less than zero
Exception Thrown: System.ArgumentOutOfRangeException

Reference:

Comment
Article Tags:

Explore