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');
Call
What 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
Parameter
Description
c
Character to test.
Return Value
Return Value
Description
true
ASCII alphanumeric.
false
Not 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('_'));
}
}
Output
True
True
False
How It Works
Letter A. Passes.
Digit 9. Passes.
Underscore fails. Not alphanumeric.
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));
}
}
Output
False
True
How It Works
ASCII false. Accented letter excluded.
Unicode true. IsLetterOrDigit accepts it.
Policy fork. Choose ASCII or Unicode alphanumeric.
.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);
}
}