title: New Distinct Extension Method for IEnumerable<T>
body: <p>I've been trying to add a new extension method for to distinct an <code>IEnumerable&lt;T&gt;</code> object. For both learning and applying purposes.</p>
  
  <p>The logic behind should do something like this : (this works)</p>
  
  <pre><code> // sis is a DbContext by the way
   List&lt;MyObj&gt; objs = sis.MyObjs.ToList();
  
   // objs contains duplicate entities
  
   List&lt;MyObj&gt; _objs = new List&lt;MyObj&gt;();
  
   foreach(MyObj e in MyObjs)
   {
       if (_ems.Contains(e) == false) _ems.Add(e);
   }
  
  
   foreach(MyObj e in _ems)
   {
       Console.WriteLine(e.ID); // Distinction happens
   }
  </code></pre>
  
  <p>I've wrote a new extension method to do the same as above lines.</p>
  
  <pre><code> public static IEnumerable&lt;T&gt; Distinct&lt;T&gt;(this IEnumerable&lt;T&gt; en)
   {
       foreach(T f in en)
       {
           if (en.Contains(f) == false) yield return f;
       }
   }
  </code></pre>
  
  <p>but it didn't work. And the strange thing is, I've also tried these (separately)</p>
  
  <pre><code>  objs.Distinct(); // default Distinct() method in Linq
    objs.GroupBy(t =&gt; t.ID).Select(t =&gt; t.FirstOrDefault());
  </code></pre>
  
  <p>but they also couldn't have distinct the objects. The only thing works, first logic that i wrote above. </p>
  
  <p>So, how could one possibly write a new extension to do the same thing as first logic does ?</p>