C# | Uri.Equals(Object) Method
Last Updated :
07 Feb, 2023
Uri.Equals(Object) Method is used to compare two Uri instances for equality.
Syntax: public override bool Equals (object comparand); Here, it takes the Uri instance or a URI identifier to compare with the current instance. Return Value: This method returns a Boolean value true if the two instances represent the same URI otherwise, false.
Below programs illustrate the use of Uri.Equals(Object) Method: Example 1:
csharp
using System;
using System.Globalization;
class GFG {
public static void Main()
{
Uri address1 = new Uri("http:
Uri address2 = new Uri("http:
bool value = address1.Equals(address2);
if (value)
Console.WriteLine("address1 is Equals to address2");
else
Console.WriteLine("address1 is not Equals to address2");
}
}
|
Output:
address1 is Equals to address2
Example 2:
csharp
using System;
using System.Globalization;
class GFG {
public static void Main()
{
get ( new Uri("http:
new Uri("http:
get ( new Uri("http:
new Uri("http:
}
public static void get (Uri address1,
Uri address2)
{
bool value = address1.Equals(address2);
if (value)
Console.WriteLine("{0} is Equals to {1}", address1, address2);
else
Console.WriteLine("{0} is not Equals to {1}", address1, address2);
}
}
|
Output:
http://www.contoso.com/ is Equals to http://www.contoso.com/
http://www.google.com/ is not Equals to http://www.facebook.com/
Reference:
Share your thoughts in the comments
Please Login to comment...