title: NET4 features: should casting generic IEnumerable<T> to IEnumerable<MoreSpecificT> be possible?
body: <p>If I have this internal method in a .NET 4 library (running on Mono here):</p>
  
  <pre><code>protected internal IEnumerable&lt;KSComponent&gt; GetComponentsByType(Type componentType)
  {
      return this.componentsDic [componentType];
  }
  </code></pre>
  
  <p>And I would like to expose it with a generic parameter for simple usage. This is what I have done so far and what is working:</p>
  
  <pre><code>public IEnumerable&lt;TComponentType&gt; GetComponentsByType&lt;TComponentType&gt;() where TComponentType : KSComponent
  {
      return this.GetComponentsByType (typeof(TComponentType)).Cast&lt;TComponentType&gt;();
  }    
  </code></pre>
  
  <p>However, shouldn't with .NET 4.0 this also work:</p>
  
  <pre><code>public IEnumerable&lt;TComponentType&gt; GetComponentsByType&lt;TComponentType&gt;() where TComponentType : KSComponent
      {
          return (IEnumerable&lt;TComponentType&gt;)this.GetComponentsByType (typeof(TComponentType));
      }
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p><code>KSComponent</code> is the base class, <code>TComponentType</code> can be (e.g.) <code>KSMoveComponent</code>, which subclasses <code>KSComponent</code>.
  The situation I have is that the class where the code above is from holds a list of <code>KSComponent</code> for a specific type, so for instance:</p>
  
  <p><code>typeof(KSMoveComponent)</code> maps to a <code>List&lt;KSComponent&gt;()</code>. All elements of the list are actually of type <code>KSMoveComponent</code>. So I'd like to have this <code>List&lt;KSComponent&gt;</code> being cast to <code>List&lt;KSMoveComponent&gt;</code> directly instead of using the <code>Linq.Cast()</code> extension.</p>
  
  <p>It's coming down to the question: I have list of cars and I can be 100% sure they all are Mercedes - why can't I get a list of Mercedes then? :-)</p>