title: C# Extend Generic Class in Method call
body: <p>I'm trying to write a method that passes a generic argument that will extend a class with a generic argument, but I don't want to have to pass a second generic argument to the method.  Is there a way to achieve what I'm trying to do without passing two generic arguments?</p>
  
  <pre><code>// this base doesn't work because it expects a BaseReportViewModel&lt;D&gt; 
  // I don't want to have to pass in two generic arguments from the child controller
  // this is what I don't want to do: this.ReportView&lt;Report1ViewModel, Report1Data&gt;(viewModel);
  // I want to ONLY have to pass in a single generic argument. 
  
  public class BaseController {
    // the below line won't compile because it expects a generic type to be passed to BaseReportViewModel&lt;&gt;
    public ActionResult ReportView&lt;T&gt;(T viewModel) where T : BaseReportViewModel {
      viewModel.ReportGroup = this.ReportGroup;
      viewModel.ReportTitle = this.ReportTitle;
      return this.View(viewModel);
    }
  }
  
  public class ChildController {  
    var viewModel = new Report1ViewModel();               
    viewModel.Data = new Report1Data();
    return this.ReportView&lt;Report1ViewModel&gt;(viewModel);            
  }
  
  public class BaseReportViewModel&lt;T&gt; : BaseViewModel where T : ReportBaseData {
    public string ReportGroup { get; set; }
    public string ReportTitle { get; set; }
    public T Data { get; set; }
  }
  
  public class Report1ViewModel : BaseReportViewModel&lt;Report1Data&gt; {
  }
  
  public class Report1Data : BaseReportData {
  }
  </code></pre>