Example #1
0
        /*
         * Also, it is STRONGLY recommended that any class that overrides Equals also override System.Object.GetHashCode.
         * Override Object.GetHashCode so that two objects that have value equality produce the same hash code.
         */

        public override int GetHashCode()
        {
            //geriausia gražinti hash code, kuris yra Equals lyginamų objekto sąvybių funkcija (mūsų atveju ChipId ir Name)
            return(ChipId.GetHashCode() ^ Name.GetHashCode());

            //vienodi (Equals) objektai visada turi gražinti tokį pat hash kodą
            //return 42; // tai neefektyvi, bet teisinga hash funkcija
            //return Owner.GetHashCode(); //tai neteisinga hash funkcija. (Naudojant Intersect nebus rastas Vilniuje ir Kaune besikartojantis šuo Miledi, nes skiriasi savininkai)
        }
Example #2
0
 public override int GetHashCode()
 {
     return(ChipId.GetHashCode() ^ Name.GetHashCode());
 }