Uri.HexEscape(Char) Method in C#


The Uri.HexEscape() method in C# is used to convert a specified character into its hexadecimal equivalent.

Syntax

Following is the syntax −

public static string HexEscape (char ch);

Above, the parameter ch is the character to convert to hexadecimal representation.

Example

Let us now see an example to implement the Uri.HexEscape() method −

using System;
public class Demo {
   public static void Main(){
      char ch = 'k';
      string res = Uri.HexEscape(ch);
      Console.WriteLine("Hexadecimal Equivalent = "+res);
   }
}

Output

This will produce the following output −

Hexadecimal Equivalent = %6B

Example

Let us now see another example to implement the Uri.HexEscape() method −

using System;
public class Demo {
   public static void Main(){
      char ch = 'P';
      string res = Uri.HexEscape(ch);
      Console.WriteLine("Hexadecimal Equivalent = "+res);
   }
}

Output

This will produce the following output −

Hexadecimal Equivalent = %50

Updated on: 14-Nov-2019

88 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements