কম্পিউটার টিউটোরিয়াল

SortedList অবজেক্ট সিঙ্ক্রোনাইজড কিনা যাচাই 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("SortedList-এর কী ও ভ্যালু...."); 
        foreach(DictionaryEntry k in list) 
            Console.WriteLine("Key: {0}, Value: {1}", k.Key, k.Value); 
        Console.WriteLine("SortedList-এ মান আছে কি? " + list.ContainsValue("Five")); 
        SortedList sortedList = SortedList.Synchronized(list); 
        Console.WriteLine("SortedList সিঙ্ক্রোনাইজড কি? = " + sortedList.IsSynchronized); 
    } 
}

আউটপুট

এটি নিচের আউটপুটটি তৈরি করবে:

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 SortedList-এ মান আছে কি? True SortedList সিঙ্ক্রোনাইজড কি? = 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("SortedList-এর কী ও ভ্যালু...."); 
        foreach(DictionaryEntry k in list) 
            Console.WriteLine("Key: {0}, Value: {1}", k.Key, k.Value); 
        Console.WriteLine("SortedList-এ মান আছে কি? " + list.ContainsValue("Ten")); 
        Console.WriteLine("SortedList সিঙ্ক্রোনাইজড কি? = " + list.IsSynchronized); 
    } 
}

আউটপুট

এটি নিচের আউটপুটটি তৈরি করবে:

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 SortedList-এ মান আছে কি? False SortedList সিঙ্ক্রোনাইজড কি? = False
  1. C#-তে ListDictionary সিঙ্ক্রোনাইজড (Thread-Safe) কিনা যাচাই করা

  2. C#-এ SortedList অবজেক্টের ফিক্সড আকার আছে কিনা যাচাই করুন

  3. C#-এ SortedList-এ নির্দিষ্ট মান আছে কিনা যাচাই করা (ContainsValue)

  4. পাইথন - নির্দিষ্ট কী (K)-এর সাথে নির্দিষ্ট মান উপস্থিত কিনা যাচাই করা