C# में Uri.Equals() मेथड दो Uri इंस्टेंस की समानता के लिए तुलना करता है।
सिंटैक्स
निम्नलिखित सिंटैक्स है:
public override bool Equals (object comparand);
यहाँ, पैरामीटर comparand वर्तमान इंस्टेंस से तुलना करने के लिए Uri इंस्टेंस या URI पहचानकर्ता है।
उदाहरण
आइए अब Uri.Equals() मेथड को लागू करने का एक उदाहरण देखें:
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!");
}
}
आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा:
URI = https://www.tutorialspoint.com/index.htm URI = https://www.tutorialspoint.com/index.htm Both the URIs aren't equal!
उदाहरण
आइए अब Uri.Equals() मेथड को लागू करने का एक और उदाहरण देखें:
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!");
}
}
आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा:
URI = https://www.tutorialspoint.com/index.htm URI = https://www.tutorialspoint.com/ Both the URIs aren't equal!