Tuples are certainly more usefull and powerfull with F#.
They can be used to bind many symbols at one time:
let (a, b, c) = (12, 3.14, "foo")
instead of:
int a = 12;
double b = 3.14;
string c = "foo"
They can be used to return multiple values (as shown upper):
let divRem a b = (a / b, a % b)
C#:
Tuple<int, int> DivRem(int a, int b)
{
return new Tuple<int, int>(a / b, a % b);
}
To access a tuple value, with F#, you can use the fst or snd functions;
let dr = divRem 27 5 // (5, 2)
let d = fst dr // 5
let r = snd dr // 2
withC# the Item1 and Item2 properties
Tuple<int, int> dr = DivRem(27 5); // <5, 2>
int d = dr.Item1; // 5
int r = dr.Item2; // 2