Uri.FromHex(Char) Método

Definición

Obtiene el valor decimal de un dígito hexadecimal.Gets the decimal value of a hexadecimal digit.

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

Dígito hexadecimal (0-9, a-f, A-F) que se va a convertir.The hexadecimal digit (0-9, a-f, A-F) to convert.

Devoluciones

Int32

Número del 0 al 15 que corresponde al dígito hexadecimal especificado.A number from 0 to 15 that corresponds to the specified hexadecimal digit.

Excepciones

digit no es un dígito hexadecimal válido (0 a 9, "a" a "f", "A" a "F").digit is not a valid hexadecimal digit (0-9, a-f, A-F).

Ejemplos

En el ejemplo siguiente se determina si un carácter es un carácter hexadecimal y, si es así, se escribe el valor decimal correspondiente en la consola.The following example determines whether a character is a hexadecimal character and, if it is, writes the corresponding decimal value to the console.

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)

Comentarios

El FromHex método convierte un carácter que representa un dígito hexadecimal (0-9, a-f, a-f) en su valor decimal (de 0 a 15).The FromHex method converts a character representing a hexadecimal digit (0-9, a-f, A-F) to its decimal value (0 to 15). Si digit no es un dígito hexadecimal válido, ArgumentException se produce una excepción.If digit is not a valid hexadecimal digit, an ArgumentException exception is thrown.

Se aplica a