// 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 hashProductName = Bar_Pos_Name == null ? 0 : Bar_Pos_Name.GetHashCode(); //Get hash code for the Code field. int hashProductCode = Bar_Pos_No.GetHashCode(); //Calculate the hash code for the product. return(hashProductName ^ hashProductCode); }
public bool Equals(BarPositions 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(Bar_Pos_Name.Equals(other.Bar_Pos_Name) && Installation_No.Equals(other.Installation_No)); }