title: Casting to Generic base class failing
body: <p>I am failing to see why my attempt to cast to a generic base class is not working.</p>
  
  <p>The basic structure of the code is as follows.</p>
  
  <pre><code>interface ICmd
  {
  }
  
  class Context
  {
  }
  
  class Cmd&lt;TContext&gt; : ICmd
      where TContext : Context
  {
  }
  
  class MyContext : Context
  {
  }
  
  class MyCmd : Cmd&lt;MyContext&gt;
  {
  }
  </code></pre>
  
  <p>So now I have an instance of ICmd and want to cast it to Cmd as follows</p>
  
  <pre><code>var base = cmd as Cmd&lt;Context&gt;
  </code></pre>
  
  <p>base is always null after this line is executed.</p>
  
  <p>changing cast to be specific for the context only and it works.</p>
  
  <pre><code>var base = cmd as Cmd&lt;MyContext&gt;       -- this works ???
  </code></pre>
  
  <p>Hope I have provided enough information, is this a covariance\contravariance issue?</p>
  
  <p>Thanks</p>