Uri.HexEscape Method

Converts a specified character into its hexadecimal equivalent.

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

public static string HexEscape (
	char character
)
public static String HexEscape (
	char character
)
public static function HexEscape (
	character : char
) : String

Parameters

character

The character to convert to hexadecimal representation.

Return Value

The hexadecimal representation of the specified character.

Exception typeCondition

ArgumentOutOfRangeException

character is greater than 255.

The following example converts a character to its hexadecimal equivalent and writes it 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 hexadecimal character", testChar);

string returnString = Uri.HexEscape(testChar);
Console.WriteLine("The hexadecimal value of '{0}' is {1}", testChar, returnString);

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show: