Generic Types and Methods
- slide 12 : 21
Variance
A
CheckAccount
is a
BankAccount
But is a
Set<CheckAccount>
a
Set<BankAccount>
?
Sets of check accounts and bank accounts.
Covariance and Contravariance - parameters
Covariance
The set types vary in the same way as the element types
Contravariance
The set types vary in the opposite way as the element types
Invariance
The set types are not affected by the variations of the element types
C# 3.0 uses invariance