Uri.IsHexDigit(Char) Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Определяет, является ли указанный символ допустимым шестнадцатеричным числом.
public:
static bool IsHexDigit(char character);
public static bool IsHexDigit(char character);
static member IsHexDigit : char -> bool
Public Shared Function IsHexDigit (character As Char) As Boolean
Параметры
- character
- Char
Символ для проверки.
Возвращаемое значение
true Значение , если символ является допустимым шестнадцатеричным числом; falseв противном случае .
Примеры
В следующем примере определяется, является ли символ шестнадцатеричным и, если это так, записывает соответствующее десятичное значение в консоль.
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)
Комментарии
Шестнадцатеричные цифры — это цифры от 0 до 9 и буквы A-F или a-f.