How to hash generic key in generic hash table implementation? class Node { public T key; public U value; public Node next; public Node(T key, U value, Node next) { this.key = key; this.value = value; this.next = next; } } public class HashTable { int length; Node[] buckets; public HashTable(int length) { this.length = length; buckets = new Node[length]; } public void Display() { for (int bucket = 0; bucket current = buckets[bucket]; Console.Write(bucket + ":"); while (current != null) { Console.Write("["+current.key+","+current.value+"]"); current=current.next; } Console.WriteLine(); } } // private int Hash(T Tkey) ... //// non-generic version of hash function private int Hash(string str) { int h=0; foreach(var s in str) h=127*h+s; return h%length; } //// public void Insert(T key, U value) { int bucket = Hash(key); buckets[bucket] = new Node(key, value, buckets[bucket]); } public U Search(T key) { Node current = buckets[Hash(key)]; while (current != null) { if (current.key.Equals(key)) return current.value; current= current.next; } throw new Exception(key+ "Not found"); }