title: Polymorphism AND type safety in parallel inheritance chains
body: <p>I have two parallel inheritance chains:</p>
  
  <pre><code>Chain1:
  Animal &lt;- Lion
         &lt;- Gazelle
  
  Chain2:
  Food   &lt;- Meat
         &lt;- Grass
  </code></pre>
  
  <p>I want to implement the "Eats" polymorphic property on Animal. This is how it looks like:</p>
  
  <pre><code>public abstract class Animal
  {
    public abstract Food Eats { get; set;}
  }
  
  
  public class Lion : Animal
  {
    public override Food Eats
    {
       get { return new Meat();}
       set 
       {
         if (value is Meat) DoSomething(value);
         else throw new Exception("Lions only eat meat. " + 
                                  "You better learn that, dude!");
       }
    }
  }
  </code></pre>
  
  <p>However, this code is not type safe. Should I feed my Lion with grass, I will be confronted with my bug only in runtime. </p>
  
  <p>Could someone provide me with a code example that facilitates type safety using Generics without sacrificing polymorphism?</p>