• VS2010 简单例子


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace SimpleVariance
    {
        class Animal { }
        class Cat: Animal { }

        class Program
        {
            // To understand what the new CoVariance and ContraVariance code does for you
            // Try deleting or adding the words out and in from the following 2 lines of code:
            delegate T Func1<out T>();
            delegate void Action1<in T>(T a);
            static void Main(string[] args)
            {
                Func1<Cat> cat = () => new Cat();
                Func1<Animal> animal = cat;

                Action1<Animal> act1 = (ani) => { Console.WriteLine(ani); };
                Action1<Cat> cat1 = act1;

                Console.WriteLine(animal());
                cat1(new Cat());
            }

        }
    }

  • 相关阅读:
    APP测试-流量测试
    APP测试-流畅度测试
    APP测试-耗电分析
    工具安装-Homebrew
    工具安装-go for Mac
    APP测试-耗电量测试
    APP测试-CPU测试
    APP测试-内存测试
    APP测试-monkey
    APP测试-adb命令
  • 原文地址:https://www.cnblogs.com/kiminozo/p/1492164.html
Copyright © 2020-2023  润新知