在Delegate当中,Variance(变异)是比较简单的理念,但不能深入理解的话,还是感觉比较疑惑的。
Covariance(协变)
- Return types are compatible
- A delegate variable can be used with a method that retures a type that is derived from the delegate's returned type
一个委托变量可以被赋值于一个方法,即使这个方法的返回值是继承于委托所定义时的返回值。
代码示例:
public class Person { } public class Employee : Person { } cla