18 May 2016

Variance in Delegates

When you assign a method to a delegate, covariance and contravariance provide flexibility for matching with method signature.


Covariance permits a method to have return type as more derived than that defined in the delegate.


Contravariance permits a method that has parameter types that are less derived than those in the delegate type.


 

No comments: