Uri.FromHex(Char) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
16 進数の 10 進値を取得します。
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
パラメーター
- digit
- Char
変換する 16 進数字 (0 から 9、a から f、A から F)。
返品
指定した 16 進数に対応する 0 から 15 までの数値。
例外
digit は有効な 16 進数 (0 から 9、a から f、A から F) ではありません。
例
次の例では、文字が 16 進文字であるかどうかを判別し、10 進文字の場合は、対応する 10 進値をコンソールに書き込みます。
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)
注釈
FromHexメソッドは、16 進数 (0 から 9、a から f、A から F) を表す文字を 10 進値 (0 から 15) に変換します。
digitが有効な 16 進数でない場合は、ArgumentException例外がスローされます。