Uri.HexEscape(Char) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Converts a specified character into its hexadecimal equivalent.
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
Parameters
- character
- Char
The character to convert to hexadecimal representation.
Returns
The hexadecimal representation of the specified character.
Exceptions
character
is greater than 255.
Examples
The following example converts a character to its hexadecimal equivalent and writes it to the console.
char testChar = 'e';
if ( Uri::IsHexDigit( testChar ) )
{
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))
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)
Applies to
Collaborer avec nous sur GitHub
La source de ce contenu se trouve sur GitHub, où vous pouvez également créer et examiner les problèmes et les demandes de tirage. Pour plus d’informations, consultez notre guide du contributeur.