C# - Character

Character

A C# char represents a single Unicode character and aliases the System.Char struct

char c = 'A';
char newLine = '\n';

A char is 16 bits wide—enough to represent any Unicode character

System.Char defines a range of static methods for working with characters, such as ToUpper, ToLower, and IsWhiteSpace.You can call these through either the System.Char type or its char alias:

Console.WriteLine (System.Char.ToUpper ('c')); // C
Console.WriteLine (char.IsWhiteSpace ('\t')); // True

Most of char’s remaining static methods are related to categorizing characters and are listed

Static methods for categorizing characters

Static method Characters included Unicode categories included
IsLetter A–Z, a–z, and letters of other alphabets UpperCaseLetter
LowerCaseLetter
TitleCaseLetter
ModifierLetter
OtherLetter
IsUpper Uppercase letters UpperCaseLetter
IsLower Lowercase letters LowerCaseLetter
IsDigit 0–9 plus digits of other alphabets DecimalDigitNumber
IsLetterOrDigit Letters plus digits Sum of IsLetter and IsDigit
IsNumber All digits plus Unicode fractions and Roman numeral symbols DecimalDigitNumber
LetterNumber
OtherNumber
IsSeparator Space plus all Unicode separator characters LineSeparator
ParagraphSeparator
IsWhiteSpace All separators plus \n, \r, \t, \f, and \v LineSeparator
ParagraphSeparator
IsPunctuation Symbols used for punctuation in Western and other alphabets DashPunctuation
ConnectorPunctuation
InitialQuotePunctuation
FinalQuotePunctuation
IsSymbol Most other printable symbols MathSymbol
ModifierSymbol
OtherSymbol
IsControl Nonprintable “control” characters below 0x20, such as \r, \n, \t, \0, and characters between 0x7F and 0x9A none