C# | Creating an empty case-sensitive HybridDictionary Class
HybridDictionary() creates an empty case-sensitive HybridDictionary.
Syntax:
public HybridDictionary ();
Below given are some examples to understand the implementation in a better way:
Example 1:
// C# code to create an empty // case-sensitive HybridDictionary. using System; using System.Collections; using System.Collections.Specialized; class GFG { // Driver code public static void Main() { // Creating an empty case-sensitive // HybridDictionary named myDict HybridDictionary myDict = new HybridDictionary(); // Adding key/value pairs in myDict myDict.Add("I", "first"); myDict.Add("II", "second"); myDict.Add("III", "third"); myDict.Add("IV", "fourth"); myDict.Add("V", "fifth"); // Displaying the key/value pairs in myDict foreach(DictionaryEntry de in myDict) Console.WriteLine(de.Key + " " + de.Value); } } |
chevron_right
filter_none
Output:
I first II second III third IV fourth V fifth
Example 2:
// C# code to create an empty // case-sensitive HybridDictionary. using System; using System.Collections; using System.Collections.Specialized; class GFG { // Driver code public static void Main() { // Creating an empty case-sensitive // HybridDictionary named myDict HybridDictionary myDict = new HybridDictionary(); // Adding key/value pairs in myDict myDict.Add("A", "Apple"); // To show that the HybridDictionary is // case-sensitive myDict.Add("a", "Air"); myDict.Add("B", "Banana"); myDict.Add("C", "Cat"); myDict.Add("D", "Dog"); myDict.Add("d", "Dolphine"); myDict.Add("E", "Elephant"); myDict.Add("F", "Fish"); // Displaying the key/value pairs in myDict foreach(DictionaryEntry de in myDict) Console.WriteLine(de.Key + " " + de.Value); } } |
chevron_right
filter_none
Output:
A Apple a Air B Banana C Cat D Dog d Dolphine E Elephant F Fish
Note:
- By default, the collection is case-sensitive.
- The comparer determines whether two keys are equal. Every key in a HybridDictionary must be unique.
- This constructor is an O(1) operation.
Reference:
- https://docs.microsoft.com/en-us/dotnet/api/system.collections.specialized.hybriddictionary.-ctor?view=netframework-4.7.2#System_Collections_Specialized_HybridDictionary__ctor
Recommended Posts:
- C# | Creating an empty HybridDictionary with specified case sensitivity
- C# | Creating a HybridDictionary with specified initial size & case sensitivity
- C# | Creating a Case-Sensitive HybridDictionary with specified initial size
- C# | HybridDictionary Class
- C# | Gets or sets the value in HybridDictionary with specified key
- C# | Adding the specified key and value into HybridDictionary
- C# | Check if HybridDictionary is read only
- C# | Removing all entries from HybridDictionary
- C# | Check the HybridDictionary for a specific key
- C# | Removing the specified key entry from HybridDictionary
- How to get Synchronize access to the HybridDictionary in C#
- C# | Get an ICollection containing the values in HybridDictionary
- C# | Get an enumerator that iterates through the HybridDictionary
- C# | Get an ICollection containing the keys in HybridDictionary
- C# | Check if two HybridDictionary objects are equal
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

