지정된 초기 크기로 HybridDictionary를 만들려면 코드는 다음과 같습니다. -
예
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("Key/Value pairs...");
foreach(DictionaryEntry d in dict)
Console.WriteLine("Key = "+d.Key + ", Value = " + d.Value);
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
Key/Value pairs... 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("Key/Value pairs...");
foreach(DictionaryEntry d in dict)
Console.WriteLine("Key = "+d.Key + ", Value = " + d.Value);
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
Key/Value pairs... 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