System.Uri.IsHexDigit 方法

方法描述

确定指定的字符是否为有效的十六进制数字。

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

public static bool IsHexDigit(
	char character
)

参数/返回值

参数值/返回值 参数类型/返回类型 参数描述/返回描述
character System-Char 要验证的字符。
返回值 System.Boolean 一个 Boolean 值。如果字符是有效的十六进制数字,则该值为 true;否则为 false。

提示和注释

十六进制数字是数字 0 到 9 和字母 A-F 或 a-f。

System.Uri.IsHexDigit 方法例子

下面的示例确定一个字符是否为十六进制字符,如果是的话,则将对应的十进制值输出到控制台。

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

异常

异常 异常描述

命名空间

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 系统要求。