C# Char IsAsciiLetterOrDigit() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Char

Definition

In C#, Char.IsAsciiLetterOrDigit returns true for ASCII letters and digits: A–Z, a–z, and 0–9.

These ASCII helpers are available in .NET 7 and later. On older runtimes, use range checks such as c >= '0' && c <= '9'.

This is a static member of System.Char. You call it with the type name, such as Char.IsAsciiLetterOrDigit(...) or char.IsAsciiLetterOrDigit(...). A char holds one 16-bit UTF-16 code unit.

Syntax

Pass a character for an ASCII alphanumeric test.

C#
bool ok = Char.IsAsciiLetterOrDigit('A');
CallWhat it does
Char.IsAsciiLetterOrDigit(c)True for ASCII letter or digit.

Underscore and punctuation return false.

Library declarations
C#
public static bool IsAsciiLetterOrDigit(char c);

Parameters

ParameterDescription
cCharacter to test.

Return Value

Return ValueDescription
trueASCII alphanumeric.
falseNot ASCII letter/digit.

C# Examples

Example 1 — Letter and Digit

Test A, 9, and underscore.

C#
using System;

class Program {
    static void Main() {
        Console.WriteLine(Char.IsAsciiLetterOrDigit('A'));
        Console.WriteLine(Char.IsAsciiLetterOrDigit('9'));
        Console.WriteLine(Char.IsAsciiLetterOrDigit('_'));
    }
}

How It Works

  1. Letter A. Passes.
  2. Digit 9. Passes.
  3. Underscore fails. Not alphanumeric.
  4. ASCII set. Classic identifier subset without _.

Example 2 — é Differs

Compare with IsLetterOrDigit.

C#
using System;

class Program {
    static void Main() {
        char c = 'é';
        Console.WriteLine(Char.IsAsciiLetterOrDigit(c));
        Console.WriteLine(Char.IsLetterOrDigit(c));
    }
}

How It Works

  1. ASCII false. Accented letter excluded.
  2. Unicode true. IsLetterOrDigit accepts it.
  3. Policy fork. Choose ASCII or Unicode alphanumeric.
  4. .NET 7+. ASCII helper availability.

Example 3 — Keep ASCII Alphanumeric

Build a simple slug fragment.

C#
using System;

class Program {
    static void Main() {
        string raw = "C#12!";
        string slug = "";
        foreach (char ch in raw) {
            if (Char.IsAsciiLetterOrDigit(ch)) slug += ch;
        }
        Console.WriteLine(slug);
    }
}

How It Works

  1. Noisy input. Hash and bang present.
  2. Filter alnum. Keep ASCII letters/digits.
  3. C12 result. Symbols removed.
  4. Slug piece. Good start for ASCII-only tokens.

Frequently Asked Questions

No.
No.
.NET 7+.
Unicode version is broader.
Yes.

Next: IsAsciiLetterUpper()

Return true for ASCII uppercase letters A–Z. .NET 7+ with System.Char.

IsAsciiLetterUpper() tutorial →

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.

13 people found this page helpful