Uri.HexEscape(Char) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将指定的字符转换为它的等效十六进制字符。
public:
static System::String ^ HexEscape(char character);
public static string HexEscape (char character);
static member HexEscape : char -> string
Public Shared Function HexEscape (character As Char) As String
参数
- character
- Char
要转换为十六进制表示形式的字符。
返回
指定字符的十六进制表示形式。
例外
character
大于 255。
示例
以下示例将字符转换为其十六进制等效项,并将其写入控制台。
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 hex character", testChar );
}
String^ returnString = Uri::HexEscape( testChar );
Console::WriteLine( "The hexadecimal value of '{0}' is {1}", testChar, returnString );
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);
let testChar = 'e'
if Uri.IsHexDigit testChar then
printfn $"'{testChar}' is the hexadecimal representation of {Uri.FromHex testChar}"
else
printfn $"'{testChar}' is not a hexadecimal character"
let returnString = Uri.HexEscape testChar
printfn $"The hexadecimal value of '{testChar}' is {returnString}"
Dim testChar As Char = "e"c
If Uri.IsHexDigit(testChar) = True Then
Console.WriteLine("'{0}' is the hexadecimal representation of {1}", testChar, Uri.FromHex(testChar))
Else
Console.WriteLine("'{0}' is not a hexadecimal character", testChar)
End If
Dim returnString As String = Uri.HexEscape(testChar)
Console.WriteLine("The hexadecimal value of '{0}' is {1}", testChar, returnString)