কম্পিউটার

একটি সাজানো তালিকা বস্তু C# এ সিঙ্ক্রোনাইজ করা হয়েছে কিনা তা পরীক্ষা করুন


একটি SortedList অবজেক্ট সিঙ্ক্রোনাইজ করা হয়েছে কিনা তা পরীক্ষা করতে, কোডটি নিম্নরূপ −

উদাহরণ

using System;
using System.Collections;
public class Demo {
   public static void Main() {
      SortedList list = new SortedList();
      list.Add("1", "One");
      list.Add("2", "Two");
      list.Add("3", "Three");
      list.Add("4", "Four");
      list.Add("5", "Five");
      list.Add("6", "Six");
      list.Add("7", "Seven");
      list.Add("8", "Eight");
      Console.WriteLine("Key and Value of SortedList....");      
      foreach(DictionaryEntry k in list )
         Console.WriteLine("Key: {0}, Value: {1}", k.Key , k.Value );
      Console.WriteLine("Is the SortedList having the value? "+list.ContainsValue("Five"));
      SortedList sortedList = SortedList.Synchronized(list);
      Console.WriteLine("Is the SortedList synchronized? = "+sortedList.IsSynchronized);
   }
}

আউটপুট

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

তৈরি করবে
Key and Value of SortedList....
Key: 1, Value: One
Key: 2, Value: Two
Key: 3, Value: Three
Key: 4, Value: Four
Key: 5, Value: Five
Key: 6, Value: Six
Key: 7, Value: Seven
Key: 8, Value: Eight
Is the SortedList having the value? True
Is the SortedList synchronized? = True

উদাহরণ

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

using System;
using System.Collections;
public class Demo {
   public static void Main() {
      SortedList list = new SortedList();
      list.Add("1", "One");
      list.Add("2", "Two");
      list.Add("3", "Three");
      list.Add("4", "Four");
      list.Add("5", "Five");
      list.Add("6", "Six");
      list.Add("7", "Seven");
      list.Add("8", "Eight");
      Console.WriteLine("Key and Value of SortedList....");
      foreach(DictionaryEntry k in list )
         Console.WriteLine("Key: {0}, Value: {1}", k.Key , k.Value );
      Console.WriteLine("Is the SortedList having the value? "+list.ContainsValue("Ten"));
      Console.WriteLine("Is the SortedList synchronized? = "+list.IsSynchronized);
   }
}

আউটপুট

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

তৈরি করবে
Key and Value of SortedList....
Key: 1, Value: One
Key: 2, Value: Two
Key: 3, Value: Three
Key: 4, Value: Four
Key: 5, Value: Five
Key: 6, Value: Six
Key: 7, Value: Seven
Key: 8, Value: Eight
Is the SortedList having the value? False
Is the SortedList synchronized? = False

  1. C# এ ListDictionary সিঙ্ক্রোনাইজ করা হয়েছে কিনা তা পরীক্ষা করে দেখুন

  2. একটি SortedList বস্তুর C# এ একটি নির্দিষ্ট আকার আছে কিনা তা পরীক্ষা করুন

  3. একটি সাজানো তালিকা বস্তুর C# এ একটি নির্দিষ্ট মান রয়েছে কিনা তা পরীক্ষা করুন

  4. পাইথন - K কী-এর সাথে সম্পর্কিত নির্দিষ্ট মান উপস্থিত আছে কিনা তা পরীক্ষা করুন