title: Implementing Linq Distinct in c#
body: <p>I have written the following code to implement <code>Linq.Distinct(IEqualityComparer)</code> in the most basic way possible, however <code>simpleCollection</code> returns 2 items instead if 1.</p>
  
  <p>Oddly, ive noticed that breakpoints on <code>Equals</code> never get hit.</p>
  
  <p>Could it be something to do with my implementation of <code>GetHashCode()</code>?</p>
  
  <pre><code>    public class testobjx
      {
          public int i { get; set; }
      }
  
      public  class mytest
      {
          public Main()
          {
              var simpleCollection = new[] { new testobjx() { i = 1 }, new testobjx() { i = 1 } }.Distinct(new DistinctCodeType());
              var itemCount = simpleCollection.Count();//this should return 1 not 2.
          }
      }
  
      public class DistinctCodeType : IEqualityComparer&lt;testobjx&gt;
      {
          public bool Equals(testobjx x, testobjx y)
          {
              return x.i == y.i;
          }
  
          public int GetHashCode(testobjx obj)
          {
              return obj.GetHashCode();
          }
      }
  </code></pre>