उदाहरण
ListDictionary की IsReadOnly प्रॉपर्टी बताती है कि डिक्शनरी रीड-ओनली है या नहीं। यह प्रॉपर्टी हमेशा false लौटाती है क्योंकि 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 तत्व...");
foreach(DictionaryEntry d in dict1) {
Console.WriteLine(d.Key + " " + d.Value);
}
Console.WriteLine("क्या ListDictionary1 का आकार निश्चित है? = " + dict1.IsFixedSize);
Console.WriteLine("क्या ListDictionary1 रीड-ओनली है? = " + dict1.IsReadOnly);
Console.WriteLine("क्या ListDictionary1 सिंक्रनाइज़्ड है? = " + dict1.IsSynchronized);
Console.WriteLine("क्या ListDictionary1 में कुंजी 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 की-वैल्यू जोड़े...");
IDictionaryEnumerator demoEnum = dict2.GetEnumerator();
while (demoEnum.MoveNext())
Console.WriteLine("Key = " + demoEnum.Key + ", Value = " + demoEnum.Value);
Console.WriteLine("क्या ListDictionary2 का आकार निश्चित है? = " + dict2.IsFixedSize);
Console.WriteLine("क्या ListDictionary2 रीड-ओनली है? = " + dict2.IsReadOnly);
Console.WriteLine("क्या ListDictionary2 सिंक्रनाइज़्ड है? = " + dict2.IsSynchronized);
Console.WriteLine("क्या ListDictionary2 में कुंजी 5 है? = " + dict2.Contains("5"));
}
}
आउटपुट
ListDictionary1 तत्व... A Books B Electronics C Smart Wearables D Pet Supplies E Clothing F Footwear क्या ListDictionary1 का आकार निश्चित है? = False क्या ListDictionary1 रीड-ओनली है? = False क्या ListDictionary1 सिंक्रनाइज़्ड है? = False क्या ListDictionary1 में कुंजी M है? = False ListDictionary2 की-वैल्यू जोड़े... Key = 1, Value = One Key = 2, Value = Two Key = 3, Value = Three Key = 4, Value = Four Key = 5, Value = Five Key = 6, Value = Six क्या ListDictionary2 का आकार निश्चित है? = False क्या ListDictionary2 रीड-ओनली है? = False क्या ListDictionary2 सिंक्रनाइज़्ड है? = False क्या ListDictionary2 में कुंजी 5 है? = True
एक और उदाहरण
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
public static void Main() {
ListDictionary dict = new ListDictionary();
dict.Add("1", "SUV");
dict.Add("2", "Sedan");
dict.Add("3", "Utility Vehicle");
dict.Add("4", "Compact Car");
dict.Add("5", "SUV");
dict.Add("6", "Sedan");
dict.Add("7", "Utility Vehicle");
dict.Add("8", "Compact Car");
dict.Add("9", "Crossover");
dict.Add("10", "Electric Car");
Console.WriteLine("ListDictionary तत्व...");
foreach(DictionaryEntry d in dict) {
Console.WriteLine(d.Key + " " + d.Value);
}
Console.WriteLine("\nक्या ListDictionary का आकार निश्चित है? = " + dict.IsFixedSize);
Console.WriteLine("क्या ListDictionary रीड-ओनली है? = " + dict.IsReadOnly);
Console.WriteLine("क्या ListDictionary सिंक्रनाइज़्ड है? = " + dict.IsSynchronized);
Console.WriteLine("क्या ListDictionary में कुंजी K है? = " + dict.Contains("K"));
Console.WriteLine("क्या ListDictionary में कुंजी 9 है? = " + dict.Contains("9"));
}
}
आउटपुट
ListDictionary तत्व... 1 SUV 2 Sedan 3 Utility Vehicle 4 Compact Car 5 SUV 6 Sedan 7 Utility Vehicle 8 Compact Car 9 Crossover 10 Electric Car क्या ListDictionary का आकार निश्चित है? = False क्या ListDictionary रीड-ओनली है? = False क्या ListDictionary सिंक्रनाइज़्ड है? = False क्या ListDictionary में कुंजी K है? = False क्या ListDictionary में कुंजी 9 है? = True