Uri.FromHex(Char) Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee haalt u de decimale waarde van een hexadecimaal cijfer op.
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
Parameters
- digit
- Char
Het hexadecimale cijfer (0-9, a-f, A-F) dat moet worden geconverteerd.
Retouren
Een getal van 0 tot 15 dat overeenkomt met het opgegeven hexadecimale cijfer.
Uitzonderingen
digit is geen geldig hexadecimaal cijfer (0-9, a-f, A-F).
Voorbeelden
In het volgende voorbeeld wordt bepaald of een teken een hexadecimaal teken is en, als dat het is, de bijbehorende decimale waarde naar de console schrijft.
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)
Opmerkingen
Met FromHex de methode wordt een teken geconverteerd dat een hexadecimaal cijfer vertegenwoordigt (0-9, a-f, A-F) naar de decimale waarde (0 tot 15). Als digit dit geen geldig hexadecimaal cijfer is, wordt er een ArgumentException uitzondering gegenereerd.