Covariance and Contravariance in C# 4.0

posted in: Language Features | 0

C# 4.0 allows to declare variance compatibility for delegates and interfaces. This means, for instance, that one can assign an IEnumerable<Cat> to an IEnumerable<Animal>. The term variance compatibility, in this context, defines the kind of assignment compatibility between two closed generic types…