title: Concise way to combine field hashcodes?
body: <p>One if the ways to implement GetHashCode - where it's required to do so - is outlined by Jon Skeet <a href="https://stackoverflow.com/questions/263400/what-is-the-best-algorithm-for-an-overridden-system-object-gethashcode">here</a>. Repeating his code:</p>
  
  <pre><code>public override int GetHashCode()
  {
      unchecked // Overflow is fine, just wrap
      {
          int hash = 17;
          // Suitable nullity checks etc, of course :)
          hash = hash * 23 + field1.GetHashCode();
          hash = hash * 23 + field2.GetHashCode();
          hash = hash * 23 + field3.GetHashCode();
          return hash;
      }
  }
  </code></pre>
  
  <p>Rolling this code by hand can be error-prone and bugs can be subtle/hard to spot (did you swap <code>+</code> and <code>*</code> by mistake?), it can be hard to remember the combination rules for different types, and I don't like expending mental effort on writing/reviewing the same thing over and over again for different fields and classes. It can also obfuscate one of the most important details (did I remember to include all the fields?) in repetitive noise. </p>
  
  <p><strong>Is there a concise way to combine field hashcodes using the .net library?</strong>. Obviously I could write my own, but if there's something idiomatic/built-in I'd prefer that. </p>
  
  <p>As an example, in Java (using JDK7) I can achieve the above using:</p>
  
  <pre><code>   @Override
     public int hashCode()  
     {  
        return Objects.hash(field1, field2, field3);  
     }  
  </code></pre>
  
  <p>This really helps to eliminate bugs and focus in the important details. </p>
  
  <p>Motivation: I came across a C# class which requires an overridden <code>GetHashCode()</code>, but the way it combined the hashcodes of its various constituents had some severe bugs. A library function for combining the hashcodes would be useful for avoiding such bugs.</p>