public void GetHashCodeTest() { PreRelease p1 = new PreRelease(PreReleaseStage.RC, 1); PreRelease p2 = new PreRelease(PreReleaseStage.RC, 1); Assert.Equal(p1.GetHashCode(), p2.GetHashCode()); }
public override int GetHashCode() { return (Major + Minor + Patch + (PreRelease.HasValue? PreRelease.GetHashCode(): 0)); }
public override int GetHashCode() { unchecked { var hashCode = Major; hashCode = (hashCode * 397) ^ Minor; hashCode = (hashCode * 397) ^ Patch; hashCode = (hashCode * 397) ^ (PreRelease != null ? PreRelease.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Build; return(hashCode); } }
public override int GetHashCode() { unchecked { var result = Major.GetHashCode(); result = result * 31 + Minor.GetHashCode(); result = result * 31 + Patch.GetHashCode(); result = result * 31 + PreRelease.GetHashCode(); result = result * 31 + Build.GetHashCode(); return(result); } }
/// <summary> /// Calculate a hash code for the version. /// </summary> public override int GetHashCode() { // The build version isn't included when calculating the hash, // as two versions with equal properties except for the build // are considered equal. unchecked // Allow integer overflow with wrapping { int hash = 17; hash = hash * 23 + Major.GetHashCode(); hash = hash * 23 + Minor.GetHashCode(); hash = hash * 23 + Patch.GetHashCode(); hash = hash * 23 + PreRelease.GetHashCode(); return(hash); } }
/// <summary> /// Generates a hash of this object data. /// </summary> /// <returns>Hash of this object.</returns> public override int GetHashCode() { int hash = 0; hash ^= Major; hash ^= Minor; hash ^= Patch; if (HasPreRelease) { hash ^= PreRelease.GetHashCode(); } if (HasBuildMetadata) { hash ^= BuildMetadata.GetHashCode(); } return(hash); }