DictionaryEntry d1 = new DictionaryEntry("key1", "value1"); DictionaryEntry d2 = new DictionaryEntry("key2", "value2");
Hashtable ht = new Hashtable(); ht.Add(1, "one"); ht.Add(2, "two"); ht.Add(3, "three"); foreach (DictionaryEntry de in ht) { Console.WriteLine("{0} = {1}", de.Key, de.Value); }In the above code, a Hashtable is defined and three key-value pairs are added to it. The foreach loop is then used to iterate through each DictionaryEntry object in the Hashtable and print out its key-value pairs. The DictionaryEntry class is a part of the System.Collections namespace in C#.