コード例 #1
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 :)

                hashCode = hashCode * 59 + IdCar.GetHashCode();
                if (CarMake != null)
                {
                    hashCode = hashCode * 59 + CarMake.GetHashCode();
                }
                if (CarName != null)
                {
                    hashCode = hashCode * 59 + CarName.GetHashCode();
                }
                if (CarNr != null)
                {
                    hashCode = hashCode * 59 + CarNr.GetHashCode();
                }
                if (CarType != null)
                {
                    hashCode = hashCode * 59 + CarType.GetHashCode();
                }
                if (CarClass != null)
                {
                    hashCode = hashCode * 59 + CarClass.GetHashCode();
                }
                return(hashCode);
            }
        }
コード例 #2
0
ファイル: Car.cs プロジェクト: plkumar/SecondMonitor
 public override int GetHashCode()
 {
     unchecked
     {
         return(((CarName != null ? CarName.GetHashCode() : 0) * 397) ^ (ClassName != null ? ClassName.GetHashCode() : 0));
     }
 }