title: Why IEqualityComparer<T> has GetHashCode() method?
body: <p><a href="http://msdn.microsoft.com/en-us/library/ms132151.aspx" rel="noreferrer">IEqualityComparer</a> in the namespace <code>System.Collections.Generic</code> has following methods:</p>
  
  <pre><code>bool Equals(T x, T y);
  int GetHashCode(T obj);
  </code></pre>
  
  <p>Since this inteface is used to check equality of objects, the first method <code>Equals</code> makes sense. But why do we need to implement <code>GetHashCode</code> also? Why does it exist in the interface in the first place? When is it needed and why?</p>
  
  <p>I'm using it with <a href="http://msdn.microsoft.com/en-us/library/bb348436.aspx" rel="noreferrer">Enumerable.Distinct()</a> method in the namespace <code>System.Linq</code>, and I'm surprised to see that even <code>GetHashCode()</code> is getting called, along with <code>Equals()</code>. Why? How does <code>Distinct</code> work?</p>