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

    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)
        {

        }
    }

  

posted on 2014-11-13 16:25  一日一进  阅读(176)  评论(0编辑  收藏  举报

导航