/// <summary> /// Returns true if Role instances are equal /// </summary> /// <param name="other">Instance of Role to be compared</param> /// <returns>Boolean</returns> public bool Equals(VoteOption other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id.Equals(other.Id) ) && ( Option == other.Option || Option != null && Option.Equals(other.Option) ) && ( TotalVotes == other.TotalVotes || TotalVotes.Equals(other.TotalVotes) ) && ( DisplayOrder == other.DisplayOrder || DisplayOrder.Equals(other.DisplayOrder) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks hash = hash * 59 + Id.GetHashCode(); if (Option != null) { hash = hash * 59 + Option.GetHashCode(); } // TotalVotes is never null hash = hash * 59 + TotalVotes.GetHashCode(); // DisplayOrder is never null, so no null check. hash = hash * 59 + DisplayOrder.GetHashCode(); return(hash); } }