System.Uri.HexEscape 方法

方法描述

将指定的字符转换它的等效十六进制字符。

语法定义(C# System.Uri.HexEscape 方法 的用法)

public static string HexEscape(
	char character
)

参数/返回值

参数值/返回值 参数类型/返回类型 参数描述/返回描述
character System-Char 要转换为十六进制表示形式的字符。
返回值 System.String 指定字符的十六进制表示形式。

提示和注释

System.Uri.HexEscape 方法例子

下面的示例将一个字符转换为它的十六进制等效项,并将它输出到控制台。

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);

异常

异常 异常描述
ArgumentOutOfRangeException character 大于 255。

命名空间

namespace: System

程序集: System(在 System.dll 中)

版本信息

.NET Framework 受以下版本支持:4、3.5、3.0、2.0、1.1、1.0 .NET Framework Client Profile 受以下版本支持:4、3.5 SP1

适用平台

Windows 7, Windows Vista SP1 或更高版本, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008(不支持服务器核心), Windows Server 2008 R2(支持 SP1 或更高版本的服务器核心), Windows Server 2003 SP2 .NET Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。