3

Possible Duplicate:
What problem was the tuple designed to solve?

Could someone please show/describe an appropriate use of the System.Tuple class?

I have looked on MSDN and the description there doesn't show any practical uses.

Community
  • 1
  • 1
Maxim Gershkovich
  • 43,966
  • 43
  • 139
  • 233

1 Answers1

1

From the MSDN on the 2-tuple:

A tuple is a data structure that has a specific number and sequence of values. The Tuple class represents a 2-tuple, or pair, which is a tuple that has two components. A 2-tuple is similar to a KeyValuePair structure.

In the Tuple<T1, T2> case, It is a generalization of the KeyValuePair<,> data structure.

Tuples are basically generic data structures. You can use them to avoid defining your own structure. An example would be for returning multiple values from a function.

It is a very useful tool in function-oriented/functional programming.

Merlyn Morgan-Graham
  • 56,626
  • 16
  • 121
  • 179