using System.Collections;
public static void Main()
Hashtable ht = new Hashtable();
Console.WriteLine($"Hash Code of component: {c.GetHashCode()}");
Console.WriteLine($"Does hashtable contain the component: {(ht.Contains(c) ? "yes" : "no")}");
Console.WriteLine($"Hash Code of component: {c.GetHashCode()} - exactly the same as previous");
Console.WriteLine($"Does hashtable contain the component: {(ht.Contains(c) ? "yes" : "no - but hash did not change")}");
ht.Add(c, "other value");
foreach (DictionaryEntry comp in ht)
Console.WriteLine($"Component with hash {comp.Key.GetHashCode()} and value: {(comp.Key as Component).value}. Hashtable entry value: {comp.Value}");
public static int idProvider = 31173;
public override int GetHashCode()
public override bool Equals(object obj)
return obj is Component component && component.id == id;