Possible duplicate:
Why isn & rsquo; t there is a common variance for classes in c # 4.0?
As a novice programmer, I have a couple of questions about deviations in .NET 4. Not much about how this works, but why some things are not options, and if other people find it useful.
Question 1:
I know that interfaces and delegates can be covariant / contravariant in .NET 4, but why not classes? So question 1:
List(of BaseClass) = List(of DerivedClass)
Is this something unsafe? Wouldn't that be helpful?
Question 2:
Question 2 follows from question 1, but may be more important for signatures than variances. Suppose I have a MustInherit class with a MustOverride member:
Public MustInherit Class TestBase
Public MustOverride Property SomeClass as BaseClass
End Class
, SomeClass BaseClass? ? , ?
Public Class TestSpecific
Inherits TestBase
Public Overrides Property SomeClass as DerivedClass
End Class
, .NET 4, .