C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Note: This gives us a pair of values, encoded in a DictionaryEntry struct value.
StructAlso: To access the key and value of a DictionaryEntry, please use the named properties.
C# program that uses DictionaryEntry type and foreach
using System;
using System.Collections;
class Program
{
    static void Main()
    {
        // Create hashtable with some keys and values.
        Hashtable hashtable = new Hashtable();
        hashtable.Add(1, "one");
        hashtable.Add(2, "two");
        hashtable.Add(3, "three");
        // Enumerate the hashtable.
        foreach (DictionaryEntry entry in hashtable)
        {
            Console.WriteLine("{0} = {1}", entry.Key, entry.Value);
        }
    }
}
Output
3 = three
2 = two
1 = one
And: The DictionaryEntry stores two object pointers, which are four bytes on 32-bit operating systems but eight bytes on 64-bit systems.
Value type: The DictionaryEntry type, as a value type, does not incur the overhead of objects.
Further: It can be instantiated anywhere in your program to store a pair of object references.