// If Equals() returns true for a pair of objects // then GetHashCode() must return the same value for these objects. public override int GetHashCode() { //Get hash code for the Name field if it is not null. int hashMarca = BrandDescription == null ? 0 : BrandDescription.GetHashCode(); //int hashIdMarca = IdMarca.GetHashCode(); //Calculate the hash code for the product. return(hashMarca); //^ hashIdMarca; }
// If Equals() returns true for a pair of objects // then GetHashCode() must return the same value for these objects. public override int GetHashCode() { //Get hash code for the modelo field if it is not null. int hashMarca = BrandDescription == null ? 0 : BrandDescription.GetHashCode(); //Get hash code for the modelo field if it is not null. int hashModelo = ModelDescription == null ? 0 : ModelDescription.GetHashCode(); //Calculate the hash code for the product. return(hashMarca ^ hashModelo); }