/// <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 :) if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (Brand != null) { hashCode = hashCode * 59 + Brand.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (Horsepower != null) { hashCode = hashCode * 59 + Horsepower.GetHashCode(); } if (Consumption != null) { hashCode = hashCode * 59 + Consumption.GetHashCode(); } if (Priceperday != null) { hashCode = hashCode * 59 + Priceperday.GetHashCode(); } return(hashCode); } }
public override int GetHashCode() { unchecked { int hash = 17; hash = (hash * 23) + Id.GetHashCode(); hash = (hash * 23) + BrandName.GetHashCode(); hash = (hash * 23) + Model.GetHashCode(); hash = (hash * 23) + Horsepower.GetHashCode(); hash = (hash * 23) + Generation.GetHashCode(); hash = (hash * 23) + ProdutionDate.GetHashCode(); hash = (hash * 23) + BrandId.GetHashCode(); return(hash); } }
/// <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 (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( Brand == other.Brand || Brand != null && Brand.Equals(other.Brand) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( Horsepower == other.Horsepower || Horsepower != null && Horsepower.Equals(other.Horsepower) ) && ( Consumption == other.Consumption || Consumption != null && Consumption.Equals(other.Consumption) ) && ( Priceperday == other.Priceperday || Priceperday != null && Priceperday.Equals(other.Priceperday) )); }