I don't see the use of 1-tuples in C#. Why do programmers use them?
Tuple Class
I have seen a declaration like the following:
Tuple<string> state;
But I wonder if there are further uses.
The Tuple classes only go up to 7. When you need an 8-tuple, you have to use
Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>>
But if you need 8 items, you probably want to redesign your application.
You can go as far as you want, as long as you chain tuples together. 15 items:
Tuple<T1, T2, T3, T4, T5, T6, T7,
Tuple<T8, T9, T10, T11, T12, T13, T14, Tuple<T15>>>
Note that C# will throw a runtime exception if the last item (TRest) is not a tuple (since it cannot be enforced at compile-time because the ITuple interface is internal
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With