Interviews1 answer
What is Co- and Contra-Variance in C#?
1 Answer
Covariance
Enables you to use a more derived type than originally specified.
You can assign an instance of IEnumerable (IEnumerable(Of Derived) in Visual Basic) to a variable of type IEnumerable .
Contravariance
Enables you to use a more generic (less derived) type than originally specified.
You can assign an instance of IEnumerable (IEnumerable(Of Base) in Visual Basic) to a variable of type IEnumerable.
kapil guptaPosted Aug 10, 2016, 1:37 AM EDT