Creating an empty case-sensitive HybridDictionary Class in C#


To create an empty case-sensitive HybridDictionary, the code is as follows −

Example

 Live Demo

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);
   }
}

Output

This will produce the following output −

Key/Value pairs...
Key = A, Value = AB
Key = B, Value = BC
Key = C, Value = DE
Key = D, Value = de

Example

Let us see another example −

 Live Demo

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);
   }
}

Output

This will produce the following output −

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

Updated on: 06-Dec-2019

67 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements