title: Cannot convert type: why is it necesssary to cast twice?
body: <p>Given this highly simplified example:</p>
  
  <pre><code>abstract class Animal { }
  
  class Dog : Animal
  {
    public void Bark() { }
  }
  class Cat : Animal
  {
    public void Mew() { }
  }
  
  class SoundRecorder&lt;T&gt; where T : Animal
  {
    private readonly T _animal;
  
    public SoundRecorder(T animal) { _animal = animal; }
  
    public void RecordSound(string fact)
    {
      if (this._animal is Dog)
      {
        ((Dog)this._animal).Bark(); // Compiler: Cannot convert type 'T' to 'Dog'.
        ((Dog)(Animal)this._animal).Bark(); // Compiles OK
      }
    }
  }
  </code></pre>
  
  <p>Why does the compiler complain about the single type cast <code>(Dog)this._animal</code>? I just can't get why compiler seems to need help by doing two casts. <code>_animal</code> cannot be anything else than an <code>Animal</code>, can it?</p>
  
  <p>Of course this question is motivated by a real life example where I had to modify existing code in a way that a similar cast was the most convenient way to do it, without refactoring the whole lot. (Yes, using composition rather than inheritance ;) ).</p>