Return a list of abstract class
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4931789/casting-listt-covariance-contravariance-problem">Casting List&lt;T&gt; - covariance/contravariance problem</a>  </p>
</blockquote>



<p>I have classes defined as below</p>

<pre><code>public abstract class AbstractDType  
{  
     protected abstract string Num1 { get; set; }  
     protected abstract string Num2 { get; set; }  
}

public class AD1 : AbstractDType  
{  
   public string Num1 { get;  set; }  
   public string Num2 { get;  set; }  
   public string Num3 { get; set;  }  
}  

public class AD2 : AbstractDType  
{  
   public string Num1 { get;  set; }  
   public string Num2 { get;  set; }  
   public string Num3 { get; set;  }   
}  

public abstract class DTypeStrategy  
{  
   protected virtual List&lt;AbstractDType&gt; GetData()  
   {  
          return new List&lt;AD1&gt;();  
   }    
}
</code></pre>

<p>I would like to return a list of PD1 (concrete type) in GetData() method. However the above code threw a casting  error . <code>List&lt;AbstractDType&gt;</code> cannot be converted to <code>List&lt;PD1&gt;</code>.  How do I fix this error so that I could return concrete in GetData method.  </p>

<p>There are other derived classes that inherited from DTypeStrategy  which would be implementing GetData() such as below : ( I am assuming that I'll get the same casting error here as well )  </p>

<pre><code>public class MyDraw : DTypeStrategy  
{  
   public override List&lt;AbstractDType&gt; GetData()  
   {  
          return new List &lt;AD2&gt;();  
   } 
}
</code></pre>
