返回类型协变和参数类型逆变

    class Animal
    { }
    class Dog : Animal
    { }

    class Program
    {
        static void Main(string[] args)
        {
            //返回类型协变
            Func<Animal, Animal> s = doThing;
            //参数类型逆变
            Action<Dog> s2 = doThing2;
        }        
        static Dog doThing(Animal x)
        {
            return null;
        }
        static void doThing2(Animal x)
        {

        }
    }

  

原文地址:https://www.cnblogs.com/luxiaobin/p/4095264.html