C# | Uri.FromHex() Method Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Uri.FromHex(Char) Method is used to get the decimal value of a hexadecimal digit. Syntax: public static int FromHex (char digit); Here, it takes the hexadecimal digit (0-9, a-f, A-F) to convert. Return Value: This method returns an Int32 value that contains a number from 0 to 15 that corresponds to the specified hexadecimal digit. Exception: This method throws ArgumentException if the digit is not a valid hexadecimal digit (0-9, a-f, A-F). Below programs illustrate the use of Uri.FromHex(Char) Method: Example 1: csharp // C# program to demonstrate the // Uri.FromHex(Char) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // Declaring and initializing Char value char value = 'A'; // Gets the decimal value // of a hexadecimal digit. // using FromHex() method int dec = Uri.FromHex(value); // Displaying the result Console.WriteLine("Converted int value : {0}", dec); } } Output: Converted int value : 10 Example 2: For ArgumentException csharp // C# program to demonstrate the // Uri.FromHex(Char) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { try { // Declaring and initializing // Char value char value = '.'; // Gets the decimal value // of a hexadecimal digit. // using FromHex() method int dec = Uri.FromHex(value); // Displaying the result Console.WriteLine("Converted int value : {0}", dec); } catch (ArgumentException e) { Console.WriteLine("Digit should be a valid "+ "Hexadecimal digit (0-9, a-f, A-F)."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: Digit should be a valid Hexadecimal digit (0-9, a-f, A-F). Exception Thrown: System.ArgumentException Reference: https://learn.microsoft.com/en-us/dotnet/api/system.uri.fromhex?view=netstandard-2.1 Comment More infoAdvertise with us Next Article C# | Uri.HexEscape(Char) Method R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Uri-Class Similar Reads C# | Uri.IsHexDigit() Method Uri.IsHexDigit(Char) Method is used to determine whether a specified character is a valid hexadecimal digit or not. Hexadecimal digits are the digits 0 to 9 and the letters A-F or a-f. Syntax: public static bool IsHexDigit (char character); Here, it takes the character to validate. Return Value: Thi 2 min read 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 1 min read C# | Uri.IsHexEncoding() Method Uri.IsHexEncoding(String, Int32) Method is used to check whether a character in a string is hexadecimal encoded or not. This checks for hexadecimal encoding which follows the pattern "%hexhex" in a string, where "hex" is a digit from 0 to 9 or a letter from A-F (case-insensitive). Syntax: public sta 2 min read C# | Uri.GetHashCode() Method Uri.GetHashCode() Method is used to get the hash code for the URI. Syntax: public override int GetHashCode (); Return Value: This method returns an Int32 containing the hash value generated for this URI. Below programs illustrate the use of Uri.GetHashCode() Method: Example 1: csharp // C# program t 1 min read C# | Uri.IsBaseOf(Uri) Method Uri.IsBaseOf(Uri) Method is used to determine whether the current Uri instance is a base of the specified Uri instance. Syntax: public bool IsBaseOf (Uri uri); Here, it takes the specified Uri instance to test.Return Value: This method returns true if the current Uri instance is a base of uri otherw 2 min read C# | Char.ToString() Method In C#, Char.ToString() is a System.Char struct method which is used to convert the value of this instance to its equivalent string representation. This method can be overloaded by passing different type of arguments to it. Char.ToString(IFormatProvider) Method Char.ToString(Char) Method Char.ToStrin 2 min read Like