title: How to retrieve an object of a specific subclass?
body: <p>I have a class 'Entity', that has a list of 'Component' objects. Now, 'Component' is just a root class for a bunch of different subclasses, and each subclass can be represented only once per entity. Now, I would like to retrieve a certain type of 'Component', how do I do that?</p>
  
  <p>It's a bit difficult to explain, but here's a code example of what I'd like to have:</p>
  
  <pre><code>class Component {...} // The root class
  class CompA : Component {...} // A type of Component
  class Entity { List&lt;Component&gt; components; } // Entity with a list of component
  
  ...
  
  Entity entity = new Entity(); // Create a new entity
  entity.components.Add(new CompA()); // Add a component of type 'CompA'
  CompA c = entity.GetComponent&lt;CompA&gt;(); // This is what I'd like to do :)
  </code></pre>