title: C# Extension method on List with specific type
body: <p>I have the following 2 extension methods</p>
  
  <pre><code>namespace Services.Resources.Extensions
  {
      public static class DataMapExtensions
      {
          public static T ToDTO&lt;T&gt;(this BaseModel model)
          {
              return Mapper.Map&lt;T&gt;(model);
          }
  
          public static List&lt;T&gt; ToDTO&lt;T&gt;(this List&lt;BaseModel&gt; models)
          {
              return Mapper.Map&lt;List&lt;T&gt;&gt;(models);
          }
  
      }
  }
  </code></pre>
  
  <p>The first method works perfectly fine.</p>
  
  <pre><code>//Note: FlightRoute inherits BaseModel
  FlightRouteDTO foo = new FlightRoute().ToDTO&lt;FlightRouteDTO&gt;(); //This works!
  </code></pre>
  
  <p>However, the second method does not seem to work.</p>
  
  <pre><code>List&lt;FlightRouteDTO&gt; bar = new List&lt;FlightRoute&gt;().ToDTO&lt;FlightRouteDTO&gt;(); //This doesn't work!
  </code></pre>
  
  <p>The compiler is saying </p>
  
  <blockquote>
    <p>Error  CS1929  'List&lt; FlightRoute>' does not contain a definition for 'ToDTO' and the best extension method overload 'DataMapExtensions.ToDTO&lt; FlightRouteDTO>(List&lt; BaseModel>)' requires a receiver of type 'List&lt; BaseModel>'</p>
  </blockquote>
  
  <p>But <code>FlightRoute</code> is of type <code>BaseModel</code>. If I change the type of <code>bar</code> to explicitly be <code>List&lt;BaseModel&gt; ...</code> then the problem goes away.</p>
  
  <pre><code>List&lt;FlightRouteDTO&gt; bar = new List&lt;BaseModel&gt;().ToDTO&lt;FlightRouteDTO&gt;(); //Why does it only work this way?
  </code></pre>
  
  <p>Am I missing something obvious?</p>