Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between System.Tuple and (,)? [duplicate]

Tags:

c#

tuples

Background: I am using two methods from different libraries; one uses System.Tuple<double,double> and the other uses (double,double) for arguments. I am finding myself unable to utilize both methods without doing extra work to convert a System.Tuple to a (,).

What is the difference between System.Tuple<t1,t2> and (t1,t2)?

like image 976
pavuxun Avatar asked Sep 06 '25 13:09

pavuxun


1 Answers

(t1,t2) is a ValueTuple<,> not a Tuple<,>

So doing the following will work:

ValueTuple<int, int> hey = (1, 2);

However, this will give you a type error

 Tuple<int, int> hey = (1, 2);

More information on the difference between ValueTuple and Tuple can be found on this question/answers What's the difference between System.ValueTuple and System.Tuple?

like image 81
Kevin Smith Avatar answered Sep 12 '25 05:09

Kevin Smith