ADVERTISEMENT
ADVERTISEMENT

Home » C#

C# | Uri.Equals() Method with Example

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

Uri.Equals() Method

Uri.Equals() method is an override method that is used to check specified reference with the current object for equality. If both are equal then it returns true otherwise it returns false.

Syntax:

    bool Uri.Equals(Uri obj);

Parameter(s):

  • Uri obj – represents the specified object to checked with current object.

Return value:

The return type of this method is Boolean, it returns a boolean value if specified object or reference is equal to the current object then it returns true otherwise it returns false.

Example to demonstrate example of Uri.Equals() method

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {
        Uri domainUri1;
        Uri domainUri2;
        Uri domainUri3;

        domainUri1 = new Uri("https://www.includehelp.com/index.html");
        domainUri2 = new Uri("https://www.includehelp.com/index.html");
        domainUri3 = new Uri("https://www.includehelp.com/index_1.html");

        if (domainUri1.Equals(domainUri1) == true)
            Console.WriteLine("Both are equal");
        else
            Console.WriteLine("Both are not equal");

        if (domainUri1.Equals(domainUri2) == true)
            Console.WriteLine("Both are equal");
        else
            Console.WriteLine("Both are not equal");

        if (domainUri1.Equals(domainUri3) == true)
            Console.WriteLine("Both are equal");
        else
            Console.WriteLine("Both are not equal");
    }
}

Output

Both are equal
Both are equal
Both are not equal
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

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.