Tuple.Create() vs new Tuple

后端 未结 5 1685
孤街浪徒
孤街浪徒 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:05

    There is no difference. If you take a look at the source code, it is doing the same thing.

    http://referencesource.microsoft.com/#mscorlib/system/tuple.cs,9124c4bea9ab0199

    For example:

    Tuple.create(1,2); 
    

    is going to call

    public static Tuple Create(T1 item1, T2 item2) {
        return new Tuple(item1, item2);
    }
    

提交回复
热议问题