public override bool Equals(Object obj) { //Check for null and compare run-time types. if (obj == null || !(obj is GUIDkey)) { return(false); } GUIDkey item = (GUIDkey)obj; return(Key == item.Key); }
static void Main(string[] args) { Guid findGUID = Guid.NewGuid(); GUIDkeyCollection gUIDkeyCollection = new GUIDkeyCollection(); gUIDkeyCollection.Add(new GUIDkey(findGUID)); gUIDkeyCollection.Add(new GUIDkey(Guid.NewGuid())); gUIDkeyCollection.Add(new GUIDkey(Guid.NewGuid())); GUIDkey findGUIDkey = gUIDkeyCollection[findGUID]; // lookup by key (behaves like a dict) Console.WriteLine(findGUIDkey.Key); Console.WriteLine(findGUIDkey.GetHashCode()); Console.WriteLine(findGUID); Console.WriteLine(findGUID.GetHashCode()); Console.ReadLine(); }