This documentation is archived and is not being maintained.

Uri.HexUnescape Method

Converts a specified hexadecimal representation of a character to the character.

Namespace:  System
Assembly:  System (in System.dll)

public static char HexUnescape(
	string pattern,
	ref int index
)

Parameters

pattern
Type: System.String

The hexadecimal representation of a character.

index
Type: System.Int32%

The location in pattern where the hexadecimal representation of a character begins.

Return Value

Type: System.Char
The character represented by the hexadecimal encoding at position index. If the character at index is not hexadecimal encoded, the character at index is returned. The value of index is incremented to point to the character following the one returned.

ExceptionCondition
ArgumentOutOfRangeException

index is less than 0 or greater than or equal to the number of characters in pattern.

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, ref index));
else
     Console.WriteLine("The character is not hexadecimal encoded");
String* testString = S"%75";
int index = 0;
if (Uri::IsHexEncoding(testString, 0))
    Console::WriteLine(S"The character is {0}", __box(Uri::HexUnescape(testString, &index)));
else
    Console::WriteLine(S"The character is not hex encoded");

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show: