C# | Uri.HexEscape(Char) Method
Uri.HexEscape(Char) Method is used to convert a specified character into its hexadecimal equivalent.
Syntax: public static string HexEscape (char character);
Here, it takes the character to convert to hexadecimal representation.
Return Value: This method returns the hexadecimal representation of the specified character.
Exception: This method throws ArgumentOutOfRangeException if character is greater than 255.
Below programs illustrate the use of Uri.HexEscape(Char) Method:
Example:
using System;
using System.Globalization;
class GFG {
public static void Main()
{
char ch = 'c' ;
string value = Uri.HexEscape(ch);
Console.WriteLine( "Hexadecimal Equivalent is: {0}" , value);
}
}
|
Output:
Hexadecimal Equivalent is: %63
Note: Character greater than 255 is not practically possible.
Reference:
Last Updated :
30 Apr, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...