英語で読む

次の方法で共有


Uri.IsHexDigit(Char) メソッド

定義

指定した文字が有効な 16 進数の数字かどうかを判断します。

C#
public static bool IsHexDigit(char character);

パラメーター

character
Char

検証対象の文字。

戻り値

文字が有効な 16 進数の値である場合は true。それ以外の場合は false

次の例では、文字が 16 進文字であるかどうかを判別し、16 進文字である場合は、対応する 10 進値をコンソールに書き込みます。

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

注釈

16 進数は、0 ~ 9 の数字と、A ~ F または a から f の文字です。

適用対象

製品 バージョン
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1