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!");
}
}
আউটপুট
এটি নিচের আউটপুট তৈরি করবে (https vs http পার্থক্যের কারণে false):
URI = https://www.tutorialspoint.com/index.htm URI = https://www.tutorialspoint.com/index.htm Both the URIs aren't equal!
পাথ পার্থক্য উদাহরণ
একই প্রোটোকল কিন্তু আলাদা পাথ থাকলে:
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!");
}
}
আউটপুট
এটি নিচের আউটপুট তৈরি করবে (পাথ পার্থক্যের কারণে false):
URI = https://www.tutorialspoint.com/index.htm URI = https://www.tutorialspoint.com/ Both the URIs aren't equal!