![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Uri.Equals(Object) Method in C#
The Uri.Equals() method in C# compares two Uri instances for equality.
Syntax
Following is the syntax −
public override bool Equals (object comparand);
Above, the parameter comparand is the Uri instance or a URI identifier to compare with the current instance.
Example
Let us now see an example to implement the Uri.Equals() method −
using System; public class Demo { public static void Main(){ Uri newURI1 = new Uri("https://www.tutorialspoint.com/index.htm"); Console.WriteLine("URI = "+newURI1); Uri newURI2 = new Uri("https://www.tutorialspoint.com/index.htm"); Console.WriteLine("URI = "+newURI2); if(newURI1.Equals(newURI2)) Console.WriteLine("Both the URIs are equal!"); else Console.WriteLine("Both the URIs aren't equal!"); } }
Output
This will produce the following output −
URI = https://www.tutorialspoint.com/index.htm URI = http://www.tutorialspoint.com/index.htm Both the URIs aren't equal!
Example
Let us now see another example to implement the Uri.Equals() method −
using System; public class Demo { public static void Main(){ Uri newURI1 = new Uri("https://www.tutorialspoint.com/index.htm"); Console.WriteLine("URI = "+newURI1); Uri newURI2 = new Uri("https://www.tutorialspoint.com/"); Console.WriteLine("URI = "+newURI2); if(newURI1.Equals(newURI2)) Console.WriteLine("Both the URIs are equal!"); else Console.WriteLine("Both the URIs aren't equal!"); } }
Output
This will produce the following output −
URI = https://www.tutorialspoint.com/index.htm URI = https://www.tutorialspoint.com/ Both the URIs aren't equal!
Advertisements