Uri.IsHexDigit(Char) Uri.IsHexDigit(Char) Uri.IsHexDigit(Char) Uri.IsHexDigit(Char) Method

定义

确定指定的字符是否为有效的十六进制数字。Determines whether a specified character is a valid hexadecimal digit.

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 Char Char Char

要验证的字符。The character to validate.

返回

如果字符是有效的十六进制数字,则为 true;否则为 falsetrue if the character is a valid hexadecimal digit; otherwise, false.

示例

下面的示例确定字符是否为十六进制字符, 如果为, 则将相应的十进制值写入控制台。The following example determines whether a character is a hexadecimal character and, if it is, writes the corresponding decimal value to the console.

char testChar = 'e';
if ( Uri::IsHexDigit( testChar ) == true )
{
   Console::WriteLine( "'{0}' is the hexadecimal representation of {1}",
      testChar, Uri::FromHex( testChar ) );
}
else
{
   Console::WriteLine( "'{0}' is not a hex character", testChar );
}

String^ returnString = Uri::HexEscape( testChar );
Console::WriteLine( "The hexadecimal value of '{0}' is {1}", testChar, returnString );
char  testChar = 'e';
if (Uri.IsHexDigit(testChar) == true)
    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);
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。Hexadecimal digits are the digits 0 to 9 and the letters A-F or a-f.

适用于