Uri.FromHex(Char) Yöntem

Tanım

Onaltılık bir rakamın ondalık değerini alır.

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

Parametreler

digit
Char

Dönüştürülecek onaltılık basamak (0-9, a-f, A-F).

Döndürülenler

Belirtilen onaltılık rakama karşılık gelen 0 ile 15 aralığında bir sayı.

Özel durumlar

digit geçerli bir onaltılık basamak değildir (0-9, a-f, A-F).

Örnekler

Aşağıdaki örnek, bir karakterin onaltılık bir karakter olup olmadığını belirler ve ise, karşılık gelen ondalık değeri konsola yazar.

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)

Açıklamalar

yöntemi, FromHex onaltılık basamayı (0-9, a-f, A-F) temsil eden bir karakteri ondalık değerine (0-15) dönüştürür. Geçerli bir onaltılık basamak değilse digit , bir ArgumentException özel durum oluşturulur.

Şunlara uygulanır