C# Uri FromHex
Description
Uri FromHex
gets the decimal value of a hexadecimal digit.
Syntax
Uri.FromHex
has the following syntax.
public static int FromHex(
char digit
)
Parameters
Uri.FromHex
has the following parameters.
digit
- The hexadecimal digit (0-9, a-f, A-F) to convert.
Returns
Uri.FromHex
method returns An Int32 value that contains a number from 0 to 15 that corresponds to the specified
hexadecimal digit.
Example
The following example determines whether a character is a hexadecimal character and, if it is, writes the corresponding decimal value to the console.
/* w ww . j a v a 2 s .co m*/
using System;
public class MainClass{
public static void Main(String[] argv){
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);
}
}
The code above generates the following result.