共用方式為


Uri.IsHexEncoding(String, Int32) 方法

定義

判斷字串中的字元是否為十六進位編碼。

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

要檢查的字串。

index
Int32

pattern 中要檢查十六進位編碼的位置。

傳回

Boolean

如果 pattern 在指定的位置為十六進位編碼,則為 true;否則為 false

範例

下列程式碼範例會判斷字元是否為十六進位編碼,如果是的話,會將對等字元寫入主控台。

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");
let testString = "%75"
let mutable index = 0
if Uri.IsHexEncoding(testString, index) then
    printfn $"The character is {Uri.HexUnescape(testString, &index)}"
else
    printfn "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 會檢查字串中模式 「%hexhex」 的十六進位編碼,其中 「hex」 是 0 到 9 的數位,或是 A-F (不區分大小寫) 的字母。

適用於