title: Convert List of Base Class to a List of Derived Class - possible?
body: <p>I coworker of mine told me that it was possible to convert a <code>List&lt;BaseClass&gt;</code> to a <code>List&lt;DerivedClass&gt;</code> (they didn't show me a working example). I didn't think it was possible to convert a parent class into a child class (I do know however that it is possible to do it the other way around). I've seen several related questions with people saying it can't be done and people saying it can - none of the proposed solutions have worked for me at all. I always get a:</p>
  
  <pre><code>System.InvalidCastException.
  Unable to cast object of type 'BaseClass' to 'ChildClass'
  </code></pre>
  
  <p>Is this absolutely possible? If so, what am I doing wrong? Here is my code (simplified for the purposes of this question):</p>
  
  <p>Parent class:</p>
  
  <pre><code>public class ParentClass
  {
      public string Name = "";
  }
  </code></pre>
  
  <p>Child class:</p>
  
  <pre><code>public class ChildClass: ParentClass
  {
      public string Date = "";
  }
  </code></pre>
  
  <p>Converting:</p>
  
  <pre><code>List&lt;ParentClass&gt; parentList = ServiceApi.GetParentClassList().ToList();
  List&lt;ChildClass&gt; childList = parentList.Cast&lt;ChildClass&gt;().ToList();
  </code></pre>
  
  <p>My actual code is significantly more complex but the same principles should apply. </p>