using System.Collections.Generic;
using System.Collections;
public static void Main()
HashSet<int> hSet = new HashSet<int>(10);
Hashtable hTable = new Hashtable();
int hashValue = GenerateHashValue(test);
Console.WriteLine(hashValue);
hashValue = GenerateHashValue("babag");
Console.WriteLine(hashValue);
private static int GenerateHashValue(string test)
for(int i=0; i< test.Length; i++)
hashValue = (int)test[i] + hashValue * 37;
private static void DisplaySet(HashSet<int> collection)
foreach (int i in collection)
Console.Write(" {0}", i);
private static void DisplayTable(Hashtable collection)
foreach( DictionaryEntry de in collection )
Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);