Beispiel #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 :)
         if (Calories != null)
         {
             hashCode = hashCode * 59 + Calories.GetHashCode();
         }
         if (DailyValues != null)
         {
             hashCode = hashCode * 59 + DailyValues.GetHashCode();
         }
         if (Fat != null)
         {
             hashCode = hashCode * 59 + Fat.GetHashCode();
         }
         if (Carbs != null)
         {
             hashCode = hashCode * 59 + Carbs.GetHashCode();
         }
         if (Vitamins != null)
         {
             hashCode = hashCode * 59 + Vitamins.GetHashCode();
         }
         return(hashCode);
     }
 }
        public override int GetHashCode()
        {
            var hashCode = -9536604;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name);

            hashCode = hashCode * -1521134295 + Protein.GetHashCode();
            hashCode = hashCode * -1521134295 + Carbohydrate.GetHashCode();
            hashCode = hashCode * -1521134295 + Fat.GetHashCode();
            hashCode = hashCode * -1521134295 + Calorific.GetHashCode();
            return(hashCode);
        }