title: Error with List<T>.Contains(T) in a LINQ query
body: <p>Wondering why this doesn't work.  Insight appreciated.</p>
  
  <pre><code>    static void Main(string[] args)
      {
          List&lt;int&gt; foo = new List&lt;int&gt; { 1, 2, 3 };
          var myResult = MyTest&lt;int&gt;(foo);
      }
  
      private static List&lt;int&gt; MyTest&lt;T&gt;(List&lt;T&gt; input)
      {
          List&lt;int&gt; bar = new List&lt;int&gt; { 2, 3, 4 };
          return bar.Where(b =&gt; input.Contains(b)).ToList();
      }
  </code></pre>
  
  <p>Expected output from MyTest() is a List { 2, 3 }.  However, the compiler reports two errors on <code>input.Contains(b)</code>, as follows:</p>
  
  <ol>
  <li><p>Argument 1: cannot convert from 'int' to 'T'</p></li>
  <li><p>The best overloaded method match for 'System.Collections.Generic.List.Contains(T)' has some invalid arguments</p></li>
  </ol>
  
  <p>This Where() clause works fine if I don't use generic lists.</p>
  
  <p>This is a simplification of my real-world problem, so please don't get stuck on "why are you writing this?"  The problem is the error and why it's occurring.</p>
  
  <p><strong>Revised for (hopefully) clarity:</strong></p>
  
  <pre><code>namespace SandBox
  {
  
  class Foo
  {
      public int FooInt { get; set; }
      public string FooString { get; set; }
  }
  
  class Program
  {
      private static List&lt;Foo&gt; fooList = new List&lt;Foo&gt; {
              new Foo() {FooInt = 1, FooString = "A"},
              new Foo() {FooInt = 2, FooString = "B"},
              new Foo() {FooInt = 3, FooString = "C"}
      };
  
      static void Main(string[] args)
      {
          List&lt;int&gt; myIntList = new List&lt;int&gt; { 1, 2 };
          var myFirstResult = GetFoos&lt;int&gt;(myIntList);
  
          List&lt;string&gt; myStringList = new List&lt;string&gt; { "A", "B" };
          var mySecondResult = GetFoos&lt;string&gt;(myStringList);
      }
  
      /// &lt;summary&gt;
      /// Return a list of Foo objects that match the input parameter list
      /// &lt;/summary&gt;
      private static List&lt;Foo&gt; GetFoos&lt;T&gt;(List&lt;T&gt; input)
      {
          //***
          // Imagine lots of code here that I don't want to duplicate in 
          // an overload of GetFoos()
          //***
  
          if (input is List&lt;int&gt;)
          {
              //Use this statement if a list of integer values was passed in
              return fooList.Where(f =&gt; input.Contains(f.FooInt));
          }
          else if (input is List&lt;string&gt;)
          {
              //Use this statement if a list of string values was passed in
              return fooList.Where(f =&gt; input.Contains(f.FooString));
          }
          else
              return null;
      }
  }
  }
  </code></pre>
  
  <p>The same compiler errors are reported on <code>input.Contains(f.Property)</code>.</p>