# Uri.FromHex(Char)Uri.FromHex(Char)Uri.FromHex(Char)Uri.FromHex(Char) Method

## 定义

public:
static int FromHex(char digit);
public static int FromHex (char digit);
static member FromHex : char -> int
Public Shared Function FromHex (digit As Char) As Integer

#### 参数

digit
Char Char Char Char

#### 异常

digit 不是有效的十六进制数字（0-9、a-f、A-F）。digit is not a valid hexadecimal digit (0-9, a-f, A-F).

## 示例

char testChar = 'e';
if ( Uri::IsHexDigit( testChar ) == true )
{
Console::WriteLine( "'{0}' is the hexadecimal representation of {1}",
testChar, Uri::FromHex( testChar ) );
}
else
{
Console::WriteLine( "'{0}' is not a hex character", testChar );
}

String^ returnString = Uri::HexEscape( testChar );
Console::WriteLine( "The hexadecimal value of '{0}' is {1}", testChar, returnString );
char  testChar = 'e';
if (Uri.IsHexDigit(testChar) == true)
Console.WriteLine("'{0}' is the hexadecimal representation of {1}", testChar, Uri.FromHex(testChar));
else
Console.WriteLine("'{0}' is not a hexadecimal character", testChar);

string returnString = Uri.HexEscape(testChar);
Console.WriteLine("The hexadecimal value of '{0}' is {1}", testChar, returnString);
Dim testChar As Char = "e"c
If Uri.IsHexDigit(testChar) = True Then
Console.WriteLine("'{0}' is the hexadecimal representation of {1}", testChar, Uri.FromHex(testChar))
Else
Console.WriteLine("'{0}' is not a hexadecimal character", testChar)
End If
Dim returnString As String = Uri.HexEscape(testChar)
Console.WriteLine("The hexadecimal value of '{0}' is {1}", testChar, returnString)

## 注解

FromHex方法将表示十六进制数字的字符 (0-9、a-f、a-f) 转换为其十进制值 (0 到 15)。The FromHex method converts a character representing a hexadecimal digit (0-9, a-f, A-F) to its decimal value (0 to 15). 如果digit不是有效的十六进制数字ArgumentException , 则会引发异常。If digit is not a valid hexadecimal digit, an ArgumentException exception is thrown.