Why won't the following code work?
class parent {} class kid:parent {} List<parent> parents=new List<kid>;
It seems obvious to me. What's going on here?
C# does not currently support covariance.
It's coming in .NET 4.0, however, on interfaces and delegates.
Eric Lippert had a very nice series on this subject on his blog awhile back. Visual Studio Magazine covers it too in a recent article.
1.4m articles
1.4m replys
5 comments
57.0k users