C# Char IsAsciiHexDigitUpper() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Char

Definition

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');
CallWhat 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

ParameterDescription
cCharacter to test.

Return Value

Return ValueDescription
trueUpper hex digit.
falseNot 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'));
    }
}

How It Works

  1. Upper A. Accepted.
  2. Lower a. Rejected.
  3. Upper style. Enforces A–F letters.
  4. .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'));
    }
}

How It Works

  1. Digit three. Always valid in hex.
  2. Letter F. Top of A–F.
  3. Both true. Upper hex alphabet.
  4. 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);
    }
}

How It Works

  1. Upper pair. FF validates.
  2. Lower pair. ff rejected.
  3. Policy print. Side-by-side outcomes.
  4. API contracts. Some formats require uppercase hex.

Frequently Asked Questions

Yes.
No.
.NET 7+.
IsAsciiHexDigit and IsAsciiHexDigitLower.
Yes.

Next: IsAsciiLetter()

Return true for ASCII letters A–Z or a–z. .NET 7+ with System.Char.

IsAsciiLetter() 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.

10 people found this page helpful