语言

Uri.HexUnescape(String, Int32) 方法

定义

将字符的指定十六进制表示形式转换为字符。

public:
 static char HexUnescape(System::String ^ pattern, int % index);
public static char HexUnescape(string pattern, ref int index);
static member HexUnescape : string * int -> char
Public Shared Function HexUnescape (pattern As String, ByRef index As Integer) As Char

参数

pattern
String

字符的十六进制表示形式。

index
Int32

字符的十六进制表示形式开始的位置 pattern 。

返回

由位置 index上的十六进制编码表示的字符。 如果字符不是 index 十六进制编码的,则返回位于的 index 字符。 该值 index 递增,以指向返回的字符之后的字符。

例外

index小于 0 或大于或等于字符数。pattern

注解

下面的代码示例确定字符是否经过十六进制编码,如果是,则向控制台写入等效字符。

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

适用于