उदाहरण
HybridDictionary कंस्ट्रक्टर एक प्रारंभिक क्षमता स्वीकार कर सकता है। यह आंतरिक डेटा संरचना (ListDictionary या Hashtable) के स्विच होने के बिंदु को अनुकूलित करने में मदद करता है।
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
public static void Main() {
HybridDictionary dict = new HybridDictionary(5);
dict.Add("A", "AB");
dict.Add("B", "BC");
dict.Add("C", "DE");
dict.Add("D", "FG");
dict.Add("E", "HI");
Console.WriteLine("की-वैल्यू जोड़े...");
foreach(DictionaryEntry d in dict)
Console.WriteLine("Key = " + d.Key + ", Value = " + d.Value);
}
}
आउटपुट
की-वैल्यू जोड़े... Key = A, Value = AB Key = B, Value = BC Key = C, Value = DE Key = D, Value = FG Key = E, Value = HI
एक और उदाहरण
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo {
public static void Main() {
HybridDictionary dict = new HybridDictionary(10);
dict.Add("1", 100);
dict.Add("2", 200);
dict.Add("3", 300);
dict.Add("4", 400);
dict.Add("5", 500);
dict.Add("6", 600);
dict.Add("7", 700);
dict.Add("8", 800);
dict.Add("9", 900);
dict.Add("10", 1000);
Console.WriteLine("की-वैल्यू जोड़े...");
foreach(DictionaryEntry d in dict)
Console.WriteLine("Key = " + d.Key + ", Value = " + d.Value);
}
}
आउटपुट
की-वैल्यू जोड़े... Key = 10, Value = 1000 Key = 1, Value = 100 Key = 2, Value = 200 Key = 3, Value = 300 Key = 4, Value = 400 Key = 5, Value = 500 Key = 6, Value = 600 Key = 7, Value = 700 Key = 8, Value = 800 Key = 9, Value = 900