Home » C#

C# | Uri.FromHex() Method with Example

Uri.FromHex() Method: Here, we are going to learn about the FromHex() method of Uri class with example in C#.
Submitted by Nidhi, on March 28, 2020

Uri.FromHex() Method

Uri.FromHex() method is a static method that returns an integer that represents a decimal digit of specified hex char.

Syntax:

    int Uri.FromHex (char ch);

Parameter(s):

  • char ch – represents the specified hex char.

Return value:

The return type of this method is int, it returns an integer that represents a decimal digit of specified hex char.

Example to demonstrate example of Uri.FromHex() method

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {
        char ch1 = 'e';
        char ch2 = 'g';

        int decimalDigit = 0;
        if (Uri.IsHexDigit(ch1))
        {
            decimalDigit = Uri.FromHex(ch1);
            Console.WriteLine("Hex Digit: {0}, decimal digit: {1}",ch1,decimalDigit);
        }
        else
            Console.WriteLine("It is not hex digit");

        if (Uri.IsHexDigit(ch2))
        {
            decimalDigit = Uri.FromHex(ch2);
            Console.WriteLine("Hex Digit : {0}, decimal digit: {1}", ch2, decimalDigit);
        }
        else
            Console.WriteLine("It is not hex digit");
    }
}

Output

Hex Digit: e, decimal digit: 14
It is not hex digit
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.