Tuple.Create() vs new Tuple

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

    The benefit of Tuple.Create is that you can usually omit the type arguments, eg. Tuple.Create(1,2) is briefer than new Tuple(1,2).

    If you try omitting the type arguments from the constructor new Tuple(1,2) you will see error CS0712 "Cannot create an instance of the static class 'Tuple""

提交回复
热议问题