title: Generic extension method : Type argument cannot be inferred from the usage
body: <p>I'm trying to create a generic extension method, that works on typed data tables :</p>
  
  <pre><code>public static class Extensions
  {
      public static TableType DoSomething&lt;TableType, RowType&gt;(this TableType table, param Expression&lt;Func&lt;RowType, bool&gt;&gt;[] predicates)
          where TableType : TypedTableBase&lt;RowType&gt;
          where RowType : DataRow
      {
          // do something to each row of the table where the row matches the predicates
          return table;
      }
  
      [STAThread]
      public static void main()
      {
          MyTypedDataSet.MyTypedDataTable table = getDefaultTable();
      }
  
      public static MyTypedDataSet.MyTypedDataTable getDefaultTable()
      {
          // this line compiles fine and does what I want:
          return new MyTypedDataSet.MyTypedDataTable().DoSomething&lt;MyTypedDataSet.MyTypedDataTable, MyTypedDataSet.MyTypedRow&gt;(row =&gt; row.Field1 == "foo");
  
          // this line doesn't compile :
          return new MyTypedDataSet.MyTypedDataTable().DoSomething(row =&gt; row.Field1 == "foo");
          // Error : The type arguments .. cannot be inferred from the usage
      }
  }
  </code></pre>
  
  <p>The first line works fine, but it's really ugly...<br>
  The second line doesn't compile because the compiler cannot infer the type of <em>RowType</em>.<br>
  This is a method that will be used as part of a DataLayer by many different programmers, so I would rather not need them to specify the TypeParameter.<br>
  Shouldn't the compiler know that <em>RowType</em> is the same type as the one that was used by TypedTableBase ?</p>
  
  <p>For different reasons that may not be obvious in this code sample, I really need to return the datatable in its original form. And the reason I need <em>RowType</em> is so the 'Expression<code>&lt;</code>Func<code>&lt;</code>T, bool><code>&gt;</code>' will be typed and seen by InteliSence.</p>
  
  <p>Thanks</p>