Home » C#

Uri.ReferenceEquals() Method with Example

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

Uri.ReferenceEquals() Method

Uri.ReferenceEquals() Method is used to check the reference of two specified objects. It is a static and override method.

Syntax:

    bool Uri.ReferenceEquals (Uri uri1, Uri uri2);

Parameter(s):

  • Uri uri1 – represents the first Uri to be compared.
  • Uri uri2 – represents the second Uri to be compared.

Return value:

The return type of this method is Boolean, it returns true if reference of two objects are equal otherwise it returns false.

Example to demonstrate example of Uri.ReferenceEquals() Method

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {
        // Create some Uri objects
        Uri uri1 = new Uri("https://www.includehelp.com/");
        Uri uri2 = new Uri("https://www.includehelp.com/");
                
        if (Uri.ReferenceEquals(uri1, uri1))
            Console.WriteLine("Both references are equal");
        else
            Console.WriteLine("Both references are not equal");

        if (Uri.ReferenceEquals(uri1, uri2))
            Console.WriteLine("Both references are equal");
        else
            Console.WriteLine("Both references are not equal");
    }
}

Output

Both references are equal
Both references are not equal


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.