Uri.FromHex(Char) Metoda

Definicja

Pobiera wartość dziesiętną cyfry szesnastkowej.

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

Parametry

digit
Char

Cyfra szesnastkowa (0-9, a-f, A-F) do konwersji.

Zwraca

Int32

Liczba z zakresu od 0 do 15, która odpowiada określonej cyfrze szesnastkowej.

Wyjątki

digit nie jest prawidłową cyfrą szesnastkową (0-9, a-f, A-F).

Przykłady

Poniższy przykład określa, czy znak jest znakiem szesnastkowym, a jeśli tak jest, zapisuje odpowiednią wartość dziesiętną w konsoli.

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

Uwagi

Metoda FromHex konwertuje znak reprezentujący cyfrę szesnastkową (0–9, a-f, A-F) na wartość dziesiętną (od 0 do 15). Jeśli digit nie jest prawidłową cyfrą szesnastkową, ArgumentException zgłaszany jest wyjątek.

Dotyczy