title: C# Cannot convert from `Inherited Class` to `Base Class`
body: <p>I've got the following code:</p>
  
  <p><strong>Simple Classes</strong></p>
  
  <pre><code>public class Transport { }
  public class Car : Transport { }
  public class Bus : Transport { }
  </code></pre>
  
  <p><strong>Wrapper Class</strong></p>
  
  <pre><code>public class Wrapper&lt;T&gt; where T : Transport
  {
      public T Vehicle { get; set; }
      public void Brake() { }
      public void Accelerate() { }
  }
  
  public class BusWrapper : Wrapper&lt;Bus&gt;
  {
      public void PickupPassenger() { }
  }
  
  public class CarWrapper : Wrapper&lt;Car&gt;
  {
      public void GoRacing() { }
  }
  </code></pre>
  
  <p>This is what I'm trying which gave me compilation error:</p>
  
  <pre><code>List&lt;Wrapper&lt;Transport&gt;&gt; list = new List&lt;Wrapper&lt;Transport&gt;&gt;();
  
  list.Add(new CarWrapper());
  list.Add(new BusWrapper());
  
  list.ForEach(wrapper =&gt;
  {
      wrapper.Accelerate();
      if (wrapper is CarWrapper)
          ((CarWrapper)wrapper).GoRacing();
      else if (wrapper is BusWrapper)
          ((BusWrapper)wrapper).PickupPassenger();
  
      wrapper.Brake();
  });
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>cannot convert from 'CarWrapper' to 'Wrapper&lt;Transport&gt;'
  cannot convert from 'BusWrapper' to 'Wrapper&lt;Transport&gt;'
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>What am I doing wrong here, any workaround for what I'm trying to achieve here.</p>
  
  <p>Thanks in advance.</p>