title: C# Generics method - calling base class constructor on a type
body: <p>I have an Object called CAR declared as follows: </p>
  
  <pre><code>public class Car{
     public int NumberOfWheels;
  }  
  </code></pre>
  
  <p>and using another class I can retrieve three of its subclasses.<br>
  As follows:</p>
  
  <pre><code>public TruckA getCarA(int param){
     return new TruckA () {NumberOfWheels = param} 
  }
  public TruckB getCarB(int param){
     return new TruckB () {NumberOfWheels = param} 
  }
  public TruckC getCarC(int param){
     return new TruckC () {NumberOfWheels = param} 
  }
  </code></pre>
  
  <p>How do I write in using generics ?<br>
  (I know it is too simple, I need an example for a more complicated case)</p>
  
  <p>I want to create a method that creates a new (T), enters the parameter and returns it.  </p>
  
  <p>something like </p>
  
  <pre><code>public TruckC getCarC(int param){
     return getTruck&lt;TruckC&gt;(param)
  }
  </code></pre>
  
  <p>Only that :<br>
  1. TruckA/B/C dont have constructor.<br>
  2. Car has no constructor. initialized using {}.<br>
  3. The method should receive only classes that derive from Car so that it can use its initialization ( {} ).</p>
  
  <p>(something equivalent to  ?? extends ? in java generics)<br>
  Possible ?  </p>
  
  <p>Thanks. </p>