// https://stackoverflow.com/questions/371328/why-is-it-important-to-override-gethashcode-when-equals-method-is-overridden public override int GetHashCode() { int hash = 13; hash = (hash * 7) + Id.GetHashCode(); hash = (hash * 7) + Author.GetHashCode(); hash = (hash * 7) + AuthorName.GetHashCode(); hash = (hash * 7) + Text.GetHashCode(); hash = (hash * 7) + Date.GetHashCode(); return(hash); }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object"/>. /// </returns> /// <filterpriority>2</filterpriority> public override int GetHashCode() { unchecked { int result = Timestamp.GetHashCode(); result = (result * 397) ^ (AuthorName != null ? AuthorName.GetHashCode() : 0); result = (result * 397) ^ (AuthorEmailAddress != null ? AuthorEmailAddress.GetHashCode() : 0); result = (result * 397) ^ (CommitMessage != null ? CommitMessage.GetHashCode() : 0); result = (result * 397) ^ (Branch != null ? Branch.GetHashCode() : 0); result = (result * 397) ^ (Hash != null ? Hash.GetHashCode() : 0); result = (result * 397) ^ (LeftParentHash != null ? LeftParentHash.GetHashCode() : 0); result = (result * 397) ^ (RightParentHash != null ? RightParentHash.GetHashCode() : 0); return(result); } }
public override int GetHashCode() { unchecked { const int randomPrime = 397; int hashCode = Id.GetHashCode(); hashCode = (hashCode * randomPrime) ^ (AuthorName != null ? AuthorName.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (AuthorFamilyName != null ? AuthorFamilyName.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (DateOfBirth != null ? DateOfBirth.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (PlaceOfBirth != null ? PlaceOfBirth.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (SharingDate != null ? SharingDate.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (TimeInterval != null ? TimeInterval.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (TypeOfInformation != null ? TypeOfInformation.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (Language != null ? Language.GetHashCode() : 0); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = (Title != null ? Title.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TitleLink != null ? TitleLink.GetHashCode() : 0); hashCode = (hashCode * 397) ^ TitleLinkDownloadable.GetHashCode(); hashCode = (hashCode * 397) ^ (Text != null ? Text.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ImageUrl != null ? ImageUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AuthorName != null ? AuthorName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AuthorIcon != null ? AuthorIcon.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ThumbUrl != null ? ThumbUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Color != null ? Color.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Timestamp.GetHashCode(); return(hashCode); } }