title: Why doesn't List.Contains work as I expect?
body: <p>Why does this program print "not added" while I think it should print "added"?</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  
  class Element
  {
      public int id;
  
      public Element(int id)
      {
          this.id = id;
      }
  
      public static implicit operator Element(int d)  
      {
          Element ret = new Element(d);
          return ret;
      }
  
      public static bool operator ==(Element e1, Element e2)
      {
          return (e1.id == e2.id);
      }
  
      public static bool operator !=(Element e1, Element e2)
      {
          return !(e1.id == e2.id);
      }
  }
  
  class MainClass
  {
      public static void Main(string[] args)
      {
          List&lt;Element&gt; element = new List&lt;Element&gt;();
          element.Add(2);
          if(element.Contains(2))
              Console.WriteLine("added");
          else
              Console.WriteLine("not added");
      }
  }
  </code></pre>
  
  <p>The <code>Contains</code> method does not use the <code>==</code> operator‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌. What is the problem?</p>