C# में Uri.Equals() विधि समानता के लिए दो Uri उदाहरणों की तुलना करती है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
public override bool Equals (object comparand);
ऊपर, पैरामीटर तुलना वर्तमान उदाहरण के साथ तुलना करने के लिए उरी इंस्टेंस या यूआरआई पहचानकर्ता है।
उदाहरण
आइए अब 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 = http://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!