char (C# reference)

The char type keyword is an alias for the .NET System.Char structure type that represents a Unicode UTF-16 character:

Type Range Size .NET type
char U+0000 to U+FFFF 16 bit System.Char

Literals

Constants of the char type can be written as character literals, hexadecimal escape sequence, or Unicode representation. You can also cast an integral character code into the corresponding char value. In the following example, the four elements of an array of char are initialized with the same character X:

var chars = new char[4];

chars[0] = 'X';        // Character literal
chars[1] = '\x0058';   // Hexadecimal
chars[2] = (char)88;   // Cast from integral type
chars[3] = '\u0058';   // Unicode

Console.Write(string.Join(" ", chars));
// Output: X X X X

Conversions

The char type is implicitly convertible to the following integral types: ushort, int, uint, long, and ulong. It's also implicitly convertible to the built-in floating-point numeric types: float, double, and decimal. It's explicitly convertible to sbyte, byte, and short integral types.

There are no implicit conversions from other types to the char type. However, any integral or floating-point numeric type is explicitly convertible to char.

C# language specification

For more information, see the Integral types section of the C# language specification.

See also