> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C# char

The `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

A `char` can be initialized using character literals enclosed in single quotation marks, Unicode escape sequences, hexadecimal escape sequences, or by explicitly casting an integer.

```csharp theme={"dark"}
char literal = 'A';
char unicodeEscape = '\u0041'; // U+0041 is 'A'
char hexEscape = '\x0041';     // Hexadecimal equivalent
char castedInt = (char)65;     // Decimal 65 maps to 'A'
```

## UTF-16 and Surrogate Pairs

Because a `char` 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`).

```csharp theme={"dark"}
// The grinning face emoji (U+1F600) requires 32 bits (two chars)
string emoji = "😀";
char highSurrogate = emoji[0]; // '\uD83D'
char lowSurrogate = emoji[1];  // '\uDE00'

bool isSurrogate = char.IsSurrogatePair(highSurrogate, lowSurrogate); // Returns true
```

## Type Conversions

The `char` 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.

```csharp theme={"dark"}
char c = 'A';

// Implicit conversions
ushort u = c;
int i = c;        // i = 65
double d = c;     // d = 65.0

// Explicit conversions (requires casting)
byte b = (byte)c; 
short s = (short)c;
```

## System.Char Mechanics

As an alias for `System.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.

```csharp theme={"dark"}
char target = '9';

bool isDigit = char.IsDigit(target);           // Evaluates Unicode category DecimalDigitNumber
bool isLetter = char.IsLetter(target);         // Evaluates Unicode category Letter
bool isWhiteSpace = char.IsWhiteSpace(target); // Evaluates Unicode category SpaceSeparator
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C# Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
