C# ValueTuple 元组 使用

有时候需要返回多个参数,或者需要一个临时模型的时候可以用这个ValueTuple 元组,感觉很好用,很酷

        static void Start() {
            var (name, age) = AAA();
            var aaa = AAA();
            List<(string, int)> list = new List<(string, int)> {
                (name, age)
            };
            Console.WriteLine(aaa.name);
            list.Add(aaa);
            list.Add(("李四", 20));
        }
        static (string name, int age) AAA() {
            return ("张三", 18);
        }

  

原文地址:https://www.cnblogs.com/luludongxu/p/15103601.html