In C#, Char.IsAsciiHexDigitUpper returns true for 0–9 and uppercase A–F only.
Lowercase a–f return false. 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.IsAsciiHexDigitUpper(...) or char.IsAsciiHexDigitUpper(...). A char holds one 16-bit UTF-16 code unit.
Syntax
Use when hex text must be uppercase.
C#
bool ok = Char.IsAsciiHexDigitUpper('A');
Call
What it does
Char.IsAsciiHexDigitUpper(c)
True for 0–9 and A–F.
Digits are allowed; letter case is restricted to upper.
Library declarations
C#
public static bool IsAsciiHexDigitUpper(char c);
Parameters
Parameter
Description
c
Character to test.
Return Value
Return Value
Description
true
Upper hex digit.
false
Not uppercase hex.
C# Examples
Example 1 — A Passes, a Fails
Compare A and a.
C#
using System;
class Program {
static void Main() {
Console.WriteLine(Char.IsAsciiHexDigitUpper('A'));
Console.WriteLine(Char.IsAsciiHexDigitUpper('a'));
}
}
Output
True
False
How It Works
Upper A. Accepted.
Lower a. Rejected.
Upper style. Enforces A–F letters.
.NET 7+. Available on recent runtimes.
Example 2 — Digits and F
Show 3 and F pass.
C#
using System;
class Program {
static void Main() {
Console.WriteLine(Char.IsAsciiHexDigitUpper('3'));
Console.WriteLine(Char.IsAsciiHexDigitUpper('F'));
}
}
Output
True
True
How It Works
Digit three. Always valid in hex.
Letter F. Top of A–F.
Both true. Upper hex alphabet.
Lower f fails. Not shown but important to remember.
Example 3 — Accept FF Only
Validate uppercase hex pair.
C#
using System;
class Program {
static void Main() {
string upper = "FF";
string lower = "ff";
bool a = Char.IsAsciiHexDigitUpper(upper[0]) && Char.IsAsciiHexDigitUpper(upper[1]);
bool b = Char.IsAsciiHexDigitUpper(lower[0]) && Char.IsAsciiHexDigitUpper(lower[1]);
Console.WriteLine("FF: " + a);
Console.WriteLine("ff: " + b);
}
}
Output
FF: True
ff: False
How It Works
Upper pair. FF validates.
Lower pair. ff rejected.
Policy print. Side-by-side outcomes.
API contracts. Some formats require uppercase hex.