title: How to force downcast on generics
body: <p>Given the code below:</p>
  
  <pre><code>class Animal
  { }
  
  class Dog : Animal
  { }
  
  class Cage&lt;T&gt;
  {
      private T animal;
  
      public Cage(T animal)
      {
          this.animal = animal;
      }
  
      public T Animal
      { 
          get { return animal;} 
      }
  }
  
  class Program
  {
      static void Main(string[] args)
      {
          Dog dog = new Dog();
          Cage&lt;Animal&gt; animalCage = new Cage&lt;Animal&gt;(dog);
          Cage&lt;Dog&gt; dogCage = (Cage&lt;Dog&gt;)animalCage;
      }
  }
  </code></pre>
  
  <p>How can I workaround the last compiler error (conversion from animalCage to dogCage)?</p>
  
  <p>In my code <strong>I know that the cage contains a dog</strong>, but I'm not able to find a way to cast to it. Is my unique alternative to create a converter and create a new <em>Cage&lt;Dog&gt;</em> instance from the value of a <em>Cage&lt;Animal&gt;</em>?</p>