.net 4.0 新特性

1、dynamic 动态类型引入

2、可选参数及指定参数赋值,参数默认值必须是常量

static void Main(string[] args)
        {
            Test(1);
            Test(par1: 1);
            Test(1, par2: 4);
            /* *
            Test(1, par2: 4, "");//前面使用了指定参数名赋值,后面必须也使用
             * */
        }

        private static void Test(int par1, int par2 = 2, string par3 = null)
        {

        }

3、还引入一些元组

Tuple

Tuple<string, int, double> tuple = new Tuple<string, int, double>("", 1, 2d);
            Console.WriteLine("{0},{1},{2}", tuple.Item1, tuple.Item2, tuple.Item3);
原文地址:https://www.cnblogs.com/CanFly/p/4313326.html