Mega Code Archive

 
Categories / C# / Network
 

Converts a specified character into its hexadecimal equivalent

using System; public class MainClass{    public static void Main(){         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);    } }