কম্পিউটার

দুটি StringCollection বস্তু C# এ সমান কিনা তা পরীক্ষা করে দেখুন


দুটি StringCollection অবজেক্ট সমান কিনা তা পরীক্ষা করতে, কোডটি নিম্নরূপ -

উদাহরণ

using System;
using System.Collections.Specialized;
public class Demo {
   public static void Main() {
      StringCollection strCol1 = new StringCollection();
      strCol1.Add("Accessories");
      strCol1.Add("Books");
      strCol1.Add("Electronics");
      Console.WriteLine("StringCollection1 elements...");
      foreach (string res in strCol1) {
         Console.WriteLine(res);
      }
      StringCollection strCol2 = new StringCollection();
      strCol2.Add("Accessories");
      strCol2.Add("Books");
      strCol2.Add("Electronics");
      Console.WriteLine("StringCollection2 elements...");
      foreach (string res in strCol1) {
         Console.WriteLine(res);
      }
      Console.WriteLine("Both the String Collections are equal? = "+strCol1.Equals(strCol2));
   }
}

আউটপুট

এটি নিম্নলিখিত আউটপুট −

তৈরি করবে
StringCollection1 elements...
Accessories
Books
Electronics
StringCollection2 elements...
Accessories
Books
Electronics
Both the String Collections are equal? = False

উদাহরণ

আসুন আরেকটি উদাহরণ দেখি -

using System;
using System.Collections.Specialized;
public class Demo {
   public static void Main() {
      StringCollection strCol1 = new StringCollection();
      strCol1.Add("Accessories");
      strCol1.Add("Books");
      strCol1.Add("Electronics");
      Console.WriteLine("StringCollection1 elements...");
      foreach (string res in strCol1) {
         Console.WriteLine(res);
      }
      StringCollection strCol2 = new StringCollection();
      strCol2.Add("Accessories");
      strCol2.Add("Books");
      strCol2.Add("Electronics");
      Console.WriteLine("StringCollection2 elements...");
      foreach (string res in strCol1) {
         Console.WriteLine(res);
      }
      Console.WriteLine("Both the String Collections are equal? = "+strCol1.Equals(strCol2));
      StringCollection strCol3 = new StringCollection();
      strCol3 = strCol2;
      Console.WriteLine("Is StringCollection3 equal to StringCollection2? = "+strCol3.Equals(strCol2));
   }
}

আউটপুট

এটি নিম্নলিখিত আউটপুট −

তৈরি করবে
StringCollection1 elements...
Accessories
Books
Electronics
StringCollection2 elements...
Accessories
Books
Electronics
Both the String Collections are equal? = False
Is StringCollection3 equal to StringCollection2? = True

  1. দুটি ম্যাট্রিক্স অভিন্ন কিনা তা পরীক্ষা করতে C# প্রোগ্রাম

  2. Python Pandas - দুটি সূচক বস্তু সমান কিনা তা নির্ধারণ করুন

  3. পাইথন - বিভাজন সমান কিনা তা পরীক্ষা করুন

  4. Python Pandas - ডেটাফ্রেম অবজেক্ট সমান কিনা তা পরীক্ষা করুন