/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) hashCode = hashCode * 59 + IdCar.GetHashCode(); if (CarMake != null) { hashCode = hashCode * 59 + CarMake.GetHashCode(); } if (CarName != null) { hashCode = hashCode * 59 + CarName.GetHashCode(); } if (CarNr != null) { hashCode = hashCode * 59 + CarNr.GetHashCode(); } if (CarType != null) { hashCode = hashCode * 59 + CarType.GetHashCode(); } if (CarClass != null) { hashCode = hashCode * 59 + CarClass.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if Car instances are equal /// </summary> /// <param name="other">Instance of Car to be compared</param> /// <returns>Boolean</returns> public bool Equals(Car other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( IdCar == other.IdCar || IdCar.Equals(other.IdCar) ) && ( CarMake == other.CarMake || CarMake != null && CarMake.Equals(other.CarMake) ) && ( CarName == other.CarName || CarName != null && CarName.Equals(other.CarName) ) && ( CarNr == other.CarNr || CarNr != null && CarNr.Equals(other.CarNr) ) && ( CarType == other.CarType || CarType != null && CarType.Equals(other.CarType) ) && ( CarClass == other.CarClass || CarClass != null && CarClass.Equals(other.CarClass) )); }