TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
char keyword in C# is an alias for the .NET System.Char structure. It is a value type that represents a single 16-bit Unicode character, specifically acting as a UTF-16 code unit.
Because it is a value type, a char is allocated on the stack when used as a local variable, or inline when embedded within a reference type or array. It occupies exactly 16 bits (2 bytes) of memory and has an underlying numeric value ranging from 0 to 65535 (U+0000 to U+FFFF).
Initialization and Syntax
Achar can be initialized using character literals enclosed in single quotation marks, Unicode escape sequences, hexadecimal escape sequences, or by explicitly casting an integer.
UTF-16 and Surrogate Pairs
Because achar is strictly 16 bits, it can only natively represent characters within the Unicode Basic Multilingual Plane (BMP). Characters outside the BMP, such as emojis or certain historical scripts, possess Unicode code points that exceed U+FFFF.
To represent these supplementary characters in C#, two consecutive char instances are required. This combination is known as a surrogate pair, consisting of a high surrogate (U+D800 to U+DBFF) and a low surrogate (U+DC00 to U+DFFF).
Type Conversions
Thechar type supports implicit conversion to larger integral and floating-point types because its 16-bit unsigned value can fit into them without data loss. Converting a char to a smaller or signed 16-bit type requires an explicit cast.
System.Char Mechanics
As an alias forSystem.Char, the char type exposes static methods designed to evaluate the Unicode category of the character. These methods evaluate the 16-bit value against Unicode standard definitions rather than relying on ASCII boundaries.
Master C# with Deep Grasping Methodology!Learn More





