HybridDictionary कंस्ट्रक्टर में bool caseInsensitive पैरामीटर होता है: false केस-सेंसिटिव (डिफ़ॉल्ट), true केस-इनसेंसिटिव के लिए। यह कुंजी तुलना व्यवहार को नियंत्रित करता है।
उदाहरण 1: केस-सेंसिटिव (false)
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo
{
public static void Main()
{
HybridDictionary dict = new HybridDictionary(false);
dict.Add("A", "AB");
dict.Add("B", "BC");
dict.Add("C", "DE");
dict.Add("D", "de");
Console.WriteLine("Key/Value pairs...");
foreach (DictionaryEntry de in dict)
Console.WriteLine("Key = " + de.Key + ", Value = " + de.Value);
}
}
आउटपुट
Key/Value pairs... Key = A, Value = AB Key = B, Value = BC Key = C, Value = DE Key = D, Value = de
उदाहरण 2: केस-इनसेंसिटिव (true)
using System;
using System.Collections;
using System.Collections.Specialized;
public class Demo
{
public static void Main()
{
HybridDictionary dict = new HybridDictionary(true);
dict.Add("A", "AB");
dict.Add("B", "BC");
dict.Add("C", "DE");
dict.Add("D", "de");
dict.Add("e", "FG");
dict.Add("F", "gh");
Console.WriteLine("Key/Value pairs...");
foreach (DictionaryEntry de in dict)
Console.WriteLine("Key = " + de.Key + ", Value = " + de.Value);
}
}
आउटपुट
Key/Value pairs... Key = A, Value = AB Key = B, Value = BC Key = C, Value = DE Key = D, Value = de Key = e, Value = FG Key = F, Value = gh
नोट: दूसरे उदाहरण में true (केस-इनसेंसिटिव) पास किया गया है, लेकिन आउटपुट में "D" और "d" दोनों अलग-अलग कुंजियों के रूप में दिखाई देते हैं, जो केस-सेंसिटिव व्यवहार दर्शाता है। यह मूल कोड/आउटपुट में विसंगति हो सकती है। केस-इनसेंसिटिव मोड में "D" और "d" समान कुंजी मानी जाती हैं; दूसरी जोड़ पहली को ओवरराइट करेगी।