C# | Uri.Equals(Object) Method Last Updated : 07 Feb, 2023 Comments Improve Suggest changes Like Article Like Report 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 // C# program to demonstrate the // Uri.Equals(Object) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // Declaring and initializing address1 Uri address1 = new Uri("http://www.contoso.com/index.htm#search"); // Declaring and initializing address2 Uri address2 = new Uri("http://www.contoso.com/index.htm"); // Comparing both instance // using Equals() method bool value = address1.Equals(address2); // Displaying the result 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 // C# program to demonstrate the // Uri.Equals(Object) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // calling get() method get(new Uri("http://www.contoso.com"), new Uri("http://www.contoso.com")); get(new Uri("http://www.google.com"), new Uri("http://www.facebook.com")); } // defining get() method public static void get(Uri address1, Uri address2) { // Comparing both instance // using Equals() method bool value = address1.Equals(address2); // Displaying the result 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: https://docs.microsoft.com/en-us/dotnet/api/system.uri.equals?view=netstandard-2.1 Comment More infoAdvertise with us Next Article C# | Uri.Equals(Object) Method R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Uri-Class Similar Reads C# | Byte.Equals(Object) Method This method is used to get a value which indicates whether the current instance is equal to a specified object or not. Syntax: public override bool Equals (object obj); Here, it takes an object to compare with the current instance or null. Return Value: This method returns true if obj is an instance 2 min read C# | Boolean.Equals(Object) Method Boolean.Equals(Object) Method is used to get a value which indicates whether the current instance is equal to a specified object or not. Syntax: public override bool Equals (object obj); Here, it takes an object to compare with the current instance. Return Value: This method returns true true if obj 2 min read C# | Type.Equals() Method Type.Equals() Method is used to check whether the underlying system type of the current Type is the same as the underlying system type of the specified Object or Type. There are 2 methods in the overload list of this method as follows: Equals(Type) Method Equals(Object) Method Type.Equals(Type) Meth 4 min read C# | Equals(String, String) Method In C#, Equals(String, String) is a String method. It is used to determine whether two String objects have the same value or not. Basically, it checks for equality. If both strings have the same value, it returns true otherwise returns false. This method is different from Compare and CompareTo method 2 min read Queue.Equals() Method in C# Equals(Object) Method which is inherited from the Object class is used to check if a specified Queue class object is equal to another Queue class object or not. This method comes under the System.Collections namespace. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is 2 min read Like