4

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)?

pavuxun
  • 411
  • 2
  • 15

2 Answers2

10

(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?

Kevin Smith
  • 13,746
  • 4
  • 52
  • 77
0

Tuple represents a single set of data. You can pass multiple values to a method by through a single Tuple parameter. You can return set of data using Tuple without using the out parameter. You can use Tuple to pass or return a max of 8 parameters from a method.