public int CompareTo(Name other) { // Compare last names. var diff = String.Compare(LastName.ToLower(), other.LastName.ToLower(), StringComparison.Ordinal); if (diff != 0) { return(diff); } // Compare first names. diff = String.Compare(FirstName.ToLower(), other.FirstName.ToLower(), StringComparison.Ordinal); if (diff != 0) { return(diff); } // Compare Middle initials diff = String.Compare(MiddleInitials.ToLower(), other.MiddleInitials.ToLower(), StringComparison.Ordinal); if (diff != 0) { return(diff); } return(0); }
/// <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 (Title != null) { hashCode = hashCode * 59 + Title.GetHashCode(); } if (Forenames != null) { hashCode = hashCode * 59 + Forenames.GetHashCode(); } if (Surname != null) { hashCode = hashCode * 59 + Surname.GetHashCode(); } if (MiddleInitials != null) { hashCode = hashCode * 59 + MiddleInitials.GetHashCode(); } if (KnownAs != null) { hashCode = hashCode * 59 + KnownAs.GetHashCode(); } hashCode = hashCode * 59 + Gender.GetHashCode(); if (DateOfBirth != null) { hashCode = hashCode * 59 + DateOfBirth.GetHashCode(); } return(hashCode); } }
public int CompareTo(Name other) { // Compare last names. var diff = LastName.ToLower().CompareTo(other.LastName.ToLower()); if (diff != 0) { return(diff); } // Compare first names. diff = FirstName.ToLower().CompareTo(other.FirstName.ToLower()); if (diff != 0) { return(diff); } // Compare Middle initials diff = MiddleInitials.ToLower().CompareTo(other.MiddleInitials.ToLower()); if (diff != 0) { return(diff); } return(0); }
/// <summary> /// Returns true if Identification instances are equal /// </summary> /// <param name="other">Instance of Identification to be compared</param> /// <returns>Boolean</returns> public bool Equals(Identification other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( StaffNumber == other.StaffNumber || StaffNumber != null && StaffNumber.Equals(other.StaffNumber) ) && ( Title == other.Title || Title != null && Title.Equals(other.Title) ) && ( Forenames == other.Forenames || Forenames != null && Forenames.Equals(other.Forenames) ) && ( Surname == other.Surname || Surname != null && Surname.Equals(other.Surname) ) && ( MiddleInitials == other.MiddleInitials || MiddleInitials != null && MiddleInitials.Equals(other.MiddleInitials) ) && ( KnownAs == other.KnownAs || KnownAs != null && KnownAs.Equals(other.KnownAs) ) && ( Gender == other.Gender || Gender.Equals(other.Gender) ) && ( DateOfBirth == other.DateOfBirth || DateOfBirth != null && DateOfBirth.Equals(other.DateOfBirth) ) && ( Ssn == other.Ssn || Ssn != null && Ssn.Equals(other.Ssn) )); }