March 2004
Intermediate to advanced
560 pages
26h 47m
English
using System; using System.Collections; namespace Samples { public class IHashCodeProviderSample { public class MyComparer: IComparer { public int Compare(Object a, Object b) { return ((IComparable)a).CompareTo(b); } } public class MyHashCodeProvider: IHashCodeProvider { public int GetHashCode(Object o) { return o.GetHashCode(); } } public static void Main() { Hashtable ht1 = new Hashtable( CaseInsensitiveHashCodeProvider.Default, new MyComparer()); Hashtable ht2 = new Hashtable(new MyHashCodeProvider(), new MyComparer()); AddEntires(ht1); AddEntires(ht2); DisplayEntires(ht1); DisplayEntires(ht2); } public static void AddEntires(Hashtable ht) { ht.Add("One","damien"); ht.Add("two", "brad"); ht.Add("Three", "mark"); ht.Add("four", "Maire"); ...Read now
Unlock full access