C# Char

Beginner
7 min read
Updated: Nov 2026
3 examples
Char

Definition and Usage

In C#, a char (System.Char) stores one 16-bit UTF-16 code unit. You write char c = 'A'; or char d = '7';. Most everyday letters and digits fit in one char. Some symbols and emoji need two code units—a surrogate pair.

The type offers helpers such as IsDigit(), IsLetter(), ToLowerInvariant(), and TryParse(). Most calls are static: Char.IsDigit(c).

This page teaches what a C# char is. The Char Methods index lists every method guide in this series.

Working with whole text?

Use string for sentences and words. Reach for Char when you already hold one character from a loop, index, or parse.

C# Syntax

Common ways to create and inspect characters:

C#
char c = 'A';                 // letter
char d = '9';                 // digit
bool ok = Char.IsDigit(d);    // True
char low = Char.ToLowerInvariant(c);
string s = c.ToString();      // "A"

char vs string

The two are easy to mix up. Here is a quick comparison:

Featurecharstring
SizeOne UTF-16 code unitZero or more chars
Literal'A' (single quotes)"Hello" (double quotes)
ClassifyChar.IsDigit(c)Loop chars or use string APIs
CaseChar.ToLowerInvariant(c)s.ToLowerInvariant()
Best forSingle-character checksWords, lines, full text

C# Examples

Three short programs that show how char works with System.Char helpers.

Example 1 — Create a char and Run Common Checks

A first program that stores letters and digits, then uses Char.Is* helpers.

C#
using System;

class Program {
    static void Main() {
        char letter = 'A';
        char digit = '7';

        Console.WriteLine("letter: " + letter);
        Console.WriteLine("IsLetter: " + Char.IsLetter(letter));
        Console.WriteLine("IsDigit: " + Char.IsDigit(digit));
        Console.WriteLine("ToLower: " + Char.ToLowerInvariant(letter));
    }
}

How It Works

  1. One code unit. Each char holds a single UTF-16 value such as 'A' or '7'.
  2. Classify. IsLetter and IsDigit answer yes/no questions about the character.
  3. Case change. ToLowerInvariant returns a new lowercase char without changing culture surprises.

Example 2 — Keep Only Letters and Digits from Text

Loop through a string and keep characters that pass IsLetterOrDigit.

C#
using System;

class Program {
    static void Main() {
        string raw = "Hi, C# 12!";
        string clean = "";

        foreach (char c in raw) {
            if (Char.IsLetterOrDigit(c)) {
                clean += c;
            }
        }

        Console.WriteLine(clean);
    }
}

How It Works

  1. Walk each char. A foreach over a string yields one char at a time.
  2. Predicate. IsLetterOrDigit is true for letters and decimal digits.
  3. Build result. Punctuation and spaces are skipped, so the cleaned text is HiC12.

Example 3 — Turn a One-Character String into a char

TryParse succeeds only when the string has exactly one character.

C#
using System;

class Program {
    static void Main() {
        string ok = "Z";
        string bad = "AB";

        if (Char.TryParse(ok, out char c)) {
            Console.WriteLine("Parsed: " + c);
        }

        Console.WriteLine("TryParse AB: " + Char.TryParse(bad, out _));
    }
}

How It Works

  1. Length one. "Z" has a single character, so parse succeeds.
  2. Out variable. The parsed char lands in c for printing.
  3. Safer than Parse. Multi-character strings return false instead of throwing.

Next: C# Char Methods Index

After you know what a char is, open the method index for a full tutorial on each System.Char API.

Start withWhy
IsDigit()Test decimal digits
IsLetter()Test letters in any script
ToLowerInvariant()Lowercase without culture surprises
TryParse()Safely parse a one-character string

Full list: C# Char Methods index (/c-sharp/char/method).

Frequently Asked Questions

A char is a 16-bit UTF-16 code unit. It stores one character such as 'A', '7', or a Unicode symbol. Some emoji need two chars (a surrogate pair).
A char is one code unit. A string is a sequence of chars. Use Char methods when you already have a single character; use string methods for whole text.
IsDigit, IsLetter, IsLetterOrDigit, IsWhiteSpace, IsLower, and IsUpper are the everyday classifiers. ASCII helpers (IsAscii*) appear in .NET 7+.
Prefer ToLowerInvariant / ToUpperInvariant (or Ordinal in .NET 7+) when the result must not depend on the user culture. Plain ToLower/ToUpper follow culture rules.
Open the C# Char Methods index. It lists IsDigit, IsLetter, ToLower, Parse, surrogates, and the rest, each with examples and FAQs.

Browse every char method

Open the methods index for categorized guides with examples and FAQs.

Char Methods Index →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful