VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-char-struct/

⇱ C# - Char Struct - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# - Char Struct

Last Updated : 11 Jul, 2025

In C#, the Char struct is used to represent a single Unicode character as a UTF-16 code unit, defined under the System namespace. A Char in C# is a 16-bit value, and it can represent characters in the Basic Multilingual Plane (BMP). Characters beyond 0xFFFF are represented by surrogate pairs (two Char values).

  • Char Struct Range: The Char range in C# is from 0x0000 to 0xFFFF. For characters outside this range, UTF-16 encoding uses a surrogate pair of Char values.
  • Unicode: Represent a Unicode character in the .NET Frameworkusing a unique 21-bit code point as defined by the Unicode Standard.
  • Methods: The Char structure provides methods to convert, compare, and check the Unicode category of a Char object.

Fields

  • MaxValue: It is a constant field that represents the largest possible value of a Char.
  • MinValue: It is a constant field that represents the smallest possible value of a Char.

Example:


Output
H h

Methods

Methods

Description

CompareTo()

Compares this char with another, returning a negative value if less, zero if equal, and positive if greater.

ConvertFromUtf32(Int32)

Converts the specified Unicode code point into a UTF-16 encoded string.

ConvertToUtf32()

Converts the value of a UTF-16 encoded surrogate pair into a Unicode code point.

Equals()

Returns a value that indicates whether this instance is equal to a specified object or Char value.

GetHashCode()

Returns the hash code for this instance.

GetNumericValue()

Converts a specified numeric Unicode character to a double-precision floating-point number.

GetTypeCode()

Returns the TypeCode for value type Char.

GetUnicodeCategory()

Categorizes a Unicode character into a group identified by one of the UnicodeCategory values.

IsControl()

Indicates whether a specified Unicode character is categorized as a control character.

IsDigit()

Indicates whether a Unicode character is categorized as a decimal digit.

IsHighSurrogate()

Indicates whether the specified Char object is a high surrogate.

IsLetter()

Indicates whether a Unicode character is categorized as a Unicode letter.

IsLetterOrDigit()

Indicates whether a Unicode character is categorized as a letter or a decimal digit.

IsLower()

Indicates whether a Unicode character is categorized as a lowercase letter.

IsLowSurrogate()

Indicates whether the specified Char object is a low surrogate.

IsNumber()

Indicates whether a Unicode character is categorized as a number.

IsPunctuation()

Indicates whether a Unicode character is categorized as a punctuation mark.

IsSeparator()

Indicates whether a Unicode character is categorized as a separator character.

IsSurrogate()

Indicates whether a character has a surrogate code unit.

IsSurrogatePair()

Indicates whether two specified Char objects form a surrogate pair.

IsSymbol()

Indicates whether a Unicode character is categorized as a symbol character.

IsUpper()

Indicates whether a Unicode character is categorized as an uppercase letter.

IsWhiteSpace()

Indicates whether a Unicode character is categorized as white space.

Parse(String)

Converts the value of the specified string to its equivalent Unicode character.

ToLower()

Converts the value of a Unicode character to its lowercase equivalent.

ToLowerInvariant(Char)

Converts the value of a Unicode character to lowercase equivalent using the casing rules of the invariant culture.

ToString()

Converts the value of this instance to its equivalent string representation.

ToUpper()

Converts the value of a Unicode character to its uppercase equivalent.

ToUpperInvariant(Char)

Converts the value of a Unicode character to its uppercase equivalent using the casing rules of the invariant culture.

TryParse(String, Char)

Converts the value of the specified string to its equivalent Unicode character. A return code indicates whether the conversion succeeded or failed.

Example 1: Using Char.CompareTo()


Output
0
-31
-6

Example 2: Using Char.IsWhiteSpace()


Output
True
True
False
Comment
Article Tags:

Explore