Uri.IsHexDigit Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Determines whether a specified character is a valid hexadecimal digit.

Namespace:  System
Assembly:  System (in System.dll)


Public Shared Function IsHexDigit ( _
    character As Char _
) As Boolean
public static bool IsHexDigit(
    char character


  • character
    Type: System.Char
    The character to validate.

Return Value

Type: System.Boolean
A Boolean value that is true if the character is a valid hexadecimal digit; otherwise false.


Hexadecimal digits are the digits 0 to 9 and the letters A-F or a-f.


The following example determines whether a character is a hexadecimal character and, if it is, writes the corresponding decimal value to the console.

Dim testChar As Char = "e"
If Uri.IsHexDigit(testChar) = True Then 
  outputBlock.Text &= testChar
  outputBlock.Text &= "is the hexadecimal representation of "
  outputBlock.Text &= Uri.FromHex(testChar)
  outputBlock.Text &= vbCrLf
  outputBlock.Text &= testChar
  outputBlock.Text &= "is not a hexadecimal character"
  outputBlock.Text &= vbCrLf
End If
char  testChar = 'e';
if (Uri.IsHexDigit(testChar) == true) {
    outputBlock.Text += testChar;
    outputBlock.Text += "is the hexadecimal representation of ";
    outputBlock.Text += Uri.FromHex(testChar);
    outputBlock.Text += "\n";
else {
    outputBlock.Text += testChar;
    outputBlock.Text += "is not a hexadecimal character\n";
char  testChar = 'e';
if (Uri.IsHexDigit(testChar) == true)
    Console.WriteLine("'{0}' is the hexadecimal representation of {1}", testChar, Uri.FromHex(testChar));
    Console.WriteLine("'{0}' is not a hexadecimal character", testChar);

Version Information


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0


For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also