title: Why is it important to override GetHashCode when Equals method is overridden?
body: <p>Given the following class</p>
  
  <pre><code>public class Foo
  {
      public int FooId { get; set; }
      public string FooName { get; set; }
  
      public override bool Equals(object obj)
      {
          Foo fooItem = obj as Foo;
  
          if (fooItem == null) 
          {
             return false;
          }
  
          return fooItem.FooId == this.FooId;
      }
  
      public override int GetHashCode()
      {
          // Which is preferred?
  
          return base.GetHashCode();
  
          //return this.FooId.GetHashCode();
      }
  }
  </code></pre>
  
  <p>I have overridden the <code>Equals</code> method because <code>Foo</code> represent a row for the <code>Foo</code>s table.  Which is the preferred method for overriding the <code>GetHashCode</code>?</p>
  
  <p>Why is it important to override <code>GetHashCode</code>?</p>