Uri.IsHexEncoding(String, Int32) Uri.IsHexEncoding(String, Int32) Uri.IsHexEncoding(String, Int32) Uri.IsHexEncoding(String, Int32) Method

定义

确定字符串中的一个字符是否为十六进制编码。Determines whether a character in a string is hexadecimal encoded.

public:
 static bool IsHexEncoding(System::String ^ pattern, int index);
public static bool IsHexEncoding (string pattern, int index);
static member IsHexEncoding : string * int -> bool
Public Shared Function IsHexEncoding (pattern As String, index As Integer) As Boolean

参数

pattern
String String String String

要检查的字符串。The string to check.

index
Int32 Int32 Int32 Int32

检查十六进制编码的 pattern 中的位置。The location in pattern to check for hexadecimal encoding.

返回

一个 Boolean 值。如果 true 在指定位置进行了十六进制编码,则该值为 pattern;否则为 falseA Boolean value that is true if pattern is hexadecimal encoded at the specified location; otherwise, false.

示例

下面的代码示例确定字符是否为十六进制编码,是否是这样,则会将等效的字符写入控制台。The following code example determines whether a character is hexadecimal encoded and, if so, writes the equivalent character to the console.

String^ testString = "%75";
int index = 0;
if ( Uri::IsHexEncoding( testString, index ) )
{
   Console::WriteLine( "The character is {0}",
      Uri::HexUnescape( testString, index ) );
}
else
{
   Console::WriteLine( "The character is not hex encoded" );
}
string testString = "%75";
int index = 0;
if (Uri.IsHexEncoding(testString, index))
     Console.WriteLine("The character is {0}", Uri.HexUnescape(testString, ref index));
else
     Console.WriteLine("The character is not hexadecimal encoded");
Dim testString As String = "%75"
Dim index As Integer = 0
If Uri.IsHexEncoding(testString, index) Then
    Console.WriteLine("The character is {0}", Uri.HexUnescape(testString, index))
Else
    Console.WriteLine("The character is not hexadecimal encoded")
End If

注解

IsHexEncoding方法检查十六进制编码,其中"hex"遵循模式遵循"%hexhex"在字符串中,为数字 0 到 9 或从 A 到 F (不区分大小写) 以字母。The IsHexEncoding method checks for hexadecimal encoding that follows the pattern "%hexhex" in a string, where "hex" is a digit from 0 to 9 or a letter from A-F (case-insensitive).

适用于