// 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 hashDCCollectorName = DCCollectorName == null ? 0 : DCCollectorName.GetHashCode(); //Get hash code for the Code field. int hashDCCollectorCode = DCCollectorName.GetHashCode(); //Calculate the hash code for the product. return(hashDCCollectorName ^ hashDCCollectorCode); }
public bool Equals(DCCollector other) { //Check whether the compared object is null. if (Object.ReferenceEquals(other, null)) { return(false); } //Check whether the compared object references the same data. if (Object.ReferenceEquals(this, other)) { return(true); } //Check whether the products' properties are equal. return(DCCollectorName.Equals(other.DCCollectorName)); }