The Uri.FromHex() method in C# is used to get the decimal value of a hexadecimal digit.
Syntax
Following is the syntax −
public static int FromHex (char digit);
Above, the parameter digit is the hexadecimal digit (0-9, a-f, A-F) to convert.
Example
Let us now see an example to implement the Uri.FromHex() method −
using System;
public class Demo {
public static void Main(){
char ch = 'D';
Console.WriteLine("Character value = "+ch);
int res = Uri.FromHex(ch);
Console.WriteLine("Converted int value = "+res);
}
}Output
This will produce the following output −
Character value = D Result = 13
Example
Let us now see another example to implement the Uri.FromHex() method −
using System;
public class Demo {
public static void Main(){
char ch = '6';
Console.WriteLine("Character value = "+ch);
int res = Uri.FromHex(ch);
Console.WriteLine("Result = "+res);
}
}Output
This will produce the following output −
Character value = 6 Result = 6