Uri.FromHex(Char) Método

Definição

Obtém o valor decimal de um dígito hexadecimal.

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

Parâmetros

digit
Char

O dígito hexadecimal (0-9, a-f, A-F) a converter.

Devoluções

Um número de 0 a 15 que corresponde ao dígito hexadecimal especificado.

Exceções

digit não é um dígito hexadecimal válido (0-9, a-f, A-F).

Exemplos

O exemplo seguinte determina se um carácter é hexadecimal e, se for, escreve o valor decimal correspondente na consola.

char  testChar = 'e';
if (Uri.IsHexDigit(testChar))
    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);
let testChar = 'e'
if Uri.IsHexDigit testChar then
    printfn $"'{testChar}' is the hexadecimal representation of {Uri.FromHex testChar}"
else
    printfn $"'{testChar}' is not a hexadecimal character"

let returnString = Uri.HexEscape testChar
printfn $"The hexadecimal value of '{testChar}' is {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)

Observações

O FromHex método converte um carácter que representa um dígito hexadecimal (0-9, a-f, A-F) para o seu valor decimal (0 a 15). Se digit não for um dígito hexadecimal válido, é lançada uma ArgumentException exceção.

Aplica-se a