ListDictionary ক্লাস একটি একক লিঙ্কযুক্ত তালিকা ব্যবহার করে আইডিকশনারি প্রয়োগ করে। এটি সংগ্রহের জন্য সুপারিশ করা হয় যেগুলি সাধারণত 10টির কম আইটেম অন্তর্ভুক্ত করে৷
৷নিচে ListDictionary ক্লাসের বৈশিষ্ট্য −
| Sr. No | সম্পত্তি এবং বর্ণনা |
|---|---|
| 1 | গণনা ListDictionary-এ থাকা কী/মান জোড়ার সংখ্যা পায়। |
| 2 | IsFixedSize৷ ListDictionary-এর একটি নির্দিষ্ট আকার আছে কিনা তা নির্দেশ করে একটি মান পায়। |
| 3 | ইজঅনলি ListDictionary শুধুমাত্র পঠনযোগ্য কিনা তা নির্দেশ করে একটি মান পায়। |
| 4 | সিঙ্ক্রোনাইজ করা হয়েছে৷ ListDictionary সিঙ্ক্রোনাইজ করা হয়েছে কিনা তা নির্দেশ করে একটি মান পায় (থ্রেড নিরাপদ)। |
| 5 | আইটেম[অবজেক্ট] নির্দিষ্ট করা মান পাওয়া বা সেট করে। |
| 6 | কী ListDictionary-এ কী সমন্বিত একটি IC Collection পায়। |
| 7 | SyncRoot ListDictionary-এ অ্যাক্সেস সিঙ্ক্রোনাইজ করতে ব্যবহার করা যেতে পারে এমন একটি বস্তু পায়। |
| 8 | মানগুলি৷ ListDictionary-এর মান সম্বলিত একটি IC Collection পায়। |
ListDictionary ক্লাস -
এর কিছু পদ্ধতি নিচে দেওয়া হল| Sr.No | পদ্ধতি এবং বর্ণনা |
|---|---|
| 1 | যোগ করুন(অবজেক্ট, অবজেক্ট) ListDictionary-এ নির্দিষ্ট কী এবং মান সহ একটি এন্ট্রি যোগ করে। |
| 2 | ক্লিয়ার()৷ ListDictionary থেকে সমস্ত এন্ট্রি সরিয়ে দেয়। |
| 3 | ধারণ করে(বস্তু) ListDictionary-এ একটি নির্দিষ্ট কী আছে কিনা তা নির্ধারণ করে। |
| 4 | CopyTo(Array, Int32)৷ নির্দিষ্ট সূচকে একটি একমাত্রিক অ্যারে উদাহরণে ListDictionary এন্ট্রিগুলি অনুলিপি করে। |
| 5 | সমান (বস্তু) নির্দিষ্ট বস্তু বর্তমান বস্তুর সমান কিনা তা নির্ধারণ করে। (অবজেক্ট থেকে উত্তরাধিকারসূত্রে প্রাপ্ত) |
| 6 | GetEnumerator() একটি IDictionaryEnumerator প্রদান করে যা ListDictionary এর মাধ্যমে পুনরাবৃত্তি করে। |
| 7 | GetHashCode() ডিফল্ট হ্যাশ ফাংশন হিসাবে কাজ করে। (অবজেক্ট থেকে উত্তরাধিকারসূত্রে প্রাপ্ত) |
| 8 | GetType() বর্তমান উদাহরণের ধরন পায়। (অবজেক্ট থেকে উত্তরাধিকারসূত্রে প্রাপ্ত) |
উদাহরণ
আসুন এখন কিছু উদাহরণ দেখি -
ListDictionary শুধুমাত্র পঠনযোগ্য কিনা তা পরীক্ষা করতে, কোডটি নিম্নরূপ -
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
public static void Main() {
ListDictionary dict1 = new ListDictionary();
dict1.Add("A", "Books");
dict1.Add("B", "Electronics");
dict1.Add("C", "Smart Wearables");
dict1.Add("D", "Pet Supplies");
dict1.Add("E", "Clothing");
dict1.Add("F", "Footwear");
Console.WriteLine("ListDictionary1 elements...");
foreach(DictionaryEntry d in dict1) {
Console.WriteLine(d.Key + " " + d.Value);
}
Console.WriteLine("Is the ListDictionary1 having fixed size? = "+dict1.IsFixedSize);
Console.WriteLine("If ListDictionary1 read-only? = "+dict1.IsReadOnly);
Console.WriteLine("Is ListDictionary1 synchronized = "+dict1.IsSynchronized);
Console.WriteLine("The ListDictionary1 has the key M? = "+dict1.Contains("M"));
ListDictionary dict2 = new ListDictionary();
dict2.Add("1", "One");
dict2.Add("2", "Two");
dict2.Add("3", "Three");
dict2.Add("4", "Four");
dict2.Add("5", "Five");
dict2.Add("6", "Six");
Console.WriteLine("\nListDictionary2 key-value pairs...");
IDictionaryEnumerator demoEnum = dict2.GetEnumerator();
while (demoEnum.MoveNext())
Console.WriteLine("Key = " + demoEnum.Key + ", Value = "+ demoEnum.Value);
Console.WriteLine("Is the ListDictionary2 having fixed size? = "+dict2.IsFixedSize);
Console.WriteLine("If ListDictionary2 read-only? = "+dict2.IsReadOnly);
Console.WriteLine("Is ListDictionary2 synchronized = "+dict2.IsSynchronized);
Console.WriteLine("The ListDictionary2 has the key 5? = "+dict2.Contains("5"));
}
} আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেListDictionary1 elements... A Books B Electronics C Smart Wearables D Pet Supplies E Clothing F Footwear Is the ListDictionary1 having fixed size? = False If ListDictionary1 read-only? = False Is ListDictionary1 synchronized = False The ListDictionary1 has the key M? = False ListDictionary2 key-value pairs... Key = 1, Value = One Key = 2, Value = Two Key = 3, Value = Three Key = 4, Value = Four Key = 5, Value = Five Key = 6, Value = Six Is the ListDictionary2 having fixed size? = False If ListDictionary2 read-only? = False Is ListDictionary2 synchronized = False The ListDictionary2 has the key 5? = True
দুটি ListDictionary অবজেক্ট সমান কিনা তা পরীক্ষা করতে, কোডটি নিম্নরূপ -
উদাহরণ
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
public static void Main() {
ListDictionary dict1 = new ListDictionary();
dict1.Add("A", "Books");
dict1.Add("B", "Electronics");
dict1.Add("C", "Smart Wearables");
dict1.Add("D", "Pet Supplies");
dict1.Add("E", "Clothing");
dict1.Add("F", "Footwear");
Console.WriteLine("ListDictionary1 elements...");
foreach(DictionaryEntry d in dict1) {
Console.WriteLine(d.Key + " " + d.Value);
}
ListDictionary dict2 = new ListDictionary();
dict2.Add("1", "One");
dict2.Add("2", "Two");
dict2.Add("3", "Three");
dict2.Add("4", "Four");
dict2.Add("5", "Five");
dict2.Add("6", "Six");
Console.WriteLine("\nListDictionary2 elements...");
foreach(DictionaryEntry d in dict2) {
Console.WriteLine(d.Key + " " + d.Value);
}
ListDictionary dict3 = new ListDictionary();
dict3 = dict2;
Console.WriteLine("\nIs ListDictionary3 equal to ListDictionary2? = "+(dict3.Equals(dict2)));
}
} আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেListDictionary1 elements... A Books B Electronics C Smart Wearables D Pet Supplies E Clothing F Footwear ListDictionary2 elements... 1 One 2 Two 3 Three 4 Four 5 Five 6 Six Is ListDictionary3 equal to ListDictionary2? = True