Like a Java's java.util.Hashtable, a .NET Hashtable is a useful data type which encapsulates key/value pairs.
Objects used as keys in a Hashtable must override or rely on the inherited GetHashCode and Equals methods of System.Object because these methods are invoked for matching. Note that the original Equals method in System.Object returns true only if both objects being compared are the same instance created on the heap. Hence, if key equality is simply reference equality, there is no need to override these methods.
The program below demonstrates how Hashtable can be used. The output is interspersed with the code to show the outputs of the different sections.
1: using System; 2: using System.Collections; 3: 4: public class ...