C# Char GetUnicodeCategory(String, Int32)

Description

Char GetUnicodeCategory(String, Int32) categorizes the character at the specified position in a specified string into a group identified by one of the UnicodeCategory values.

Syntax

Char.GetUnicodeCategory(String, Int32) has the following syntax.


public static UnicodeCategory GetUnicodeCategory(
  string s,
  int index
)

Parameters

Char.GetUnicodeCategory(String, Int32) has the following parameters.

  • s - A String.
  • index - The character position in s.

Returns

Char.GetUnicodeCategory(String, Int32) method returns A UnicodeCategory enumerated constant that identifies the group that contains the character at position index in s.

Example

The following example demonstrates GetUnicodeCategory.


/* w w w . j  a  v a2s .c om*/
using System;

public class MainClass {
  public static void Main() {
    char ch2 = '2';
    string str = "Upper Case";

    Console.WriteLine(Char.GetUnicodeCategory('a'));    // Output: "LowercaseLetter"
    Console.WriteLine(Char.GetUnicodeCategory(ch2));    // Output: "DecimalDigitNumber"
    Console.WriteLine(Char.GetUnicodeCategory(str, 6));    // Output: "UppercaseLetter"
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version