Tuple.Create() vs new Tuple

后端 未结 5 1673
孤街浪徒
孤街浪徒 2021-02-02 06:18

Consider the following expressions:

new Tuple(1,2);

Tuple.Create(1,2);

Is there any difference between these two methods of Tup

5条回答
  •  后悔当初
    2021-02-02 07:12

    Starting with C# 7, you can now simply declare Value Tuple like so:

    var unnamed = (1, 2);
    

    or

    var named = (name: "Joe", age: 2);
    

    See microsoft documentation here: https://docs.microsoft.com/en-us/dotnet/csharp/tuples

提交回复
热议问题