HexEscape Method

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
Not applicable.

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 Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2016 Microsoft