C# 4.0

 序言

动态绑定-dynamic

class Program
{
    static void Main(string[] args)
    {
        dynamic dyn = 1;
        object obj = 1;

        // Rest the mouse pointer over dyn and obj to see their
        // types at compile time.
        System.Console.WriteLine(dyn.GetType());
        System.Console.WriteLine(obj.GetType());
    }
}
View Code

命名参数/可选参数

可选参数允许为方法的一些参数提供默认值,并允许使用者重载类型,因此,即使只有一个方法,也能处理所有变体

public void test(string a, string b, int c, bool d=true,bool e=false)
{

}

调用:

public void invoke()
{
      test("li", "dd",7);
      test("li", "dd", 7,false);
      test("li", "dd", 7, true,false);
}

泛型协变和逆变

嵌入的互操作类型

资料

原文地址:https://www.cnblogs.com/cnki/p/12005239.html