System.Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> Class

Represents an n-tuple, where n is 8 or greater.

See Also: Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> Members

Syntax

public class Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> : IStructuralComparable, IStructuralEquatable, IComparable, ITuple

Type Parameters

T1
Documentation for this section has not yet been entered.
T2
Documentation for this section has not yet been entered.
T3
Documentation for this section has not yet been entered.
T4
Documentation for this section has not yet been entered.
T5
Documentation for this section has not yet been entered.
T6
Documentation for this section has not yet been entered.
T7
Documentation for this section has not yet been entered.
TRest
Documentation for this section has not yet been entered.

Remarks

A tuple is a data structure that has a specific number and sequence of values. The Tuple`8 class represents an n-tuple that has eight or more components.

You can instantiate a Tuple`8 object with exactly eight components by calling the static Tuple.Create``8(``0, ``1, ``2, ``3, ``4, ``5, ``6, ``7) method. The following example creates an 8-tuple (octuple) that contains prime numbers that are less than 20. Note that it uses type inference to determine the type of each component.

code reference: System.Tuple.Create#17

You can also instantiate an n-tuple object with eight or more components by calling the Tuple`8.#ctor(`0, `1, `2, `3, `4, `5, `6, `7) constructor. The following example uses the Tuple`8.#ctor(`0, `1, `2, `3, `4, `5, `6, `7) constructor to create an 8-tuple that is equivalent to the tuple created in the previous example.

code reference: System.Tuple`8.Class#1

Note:

To create an n-tuple with nine or more components, you must call the Tuple`8.#ctor(`0, `1, `2, `3, `4, `5, `6, `7) constructor. The static factory methods of the Tuple class do not support the creation of Tuple objects with more than eight components.

To instantiate an n-tuple that has eight or more components with the Tuple`8.#ctor(`0, `1, `2, `3, `4, `5, `6, `7) constructor, you supply a generic Tuple object as the rest parameter to define the eighth through nth components of the tuple. By nesting generic Tuple objects in this way, you can create a tuple that has no practical limitation on the number of its components.

The following example creates a 17-tuple that contains population data for the city of Detroit, Michigan, for each national census from 1860 to 2000. The first component of the tuple is the city name. The second component is the start date of the data series, and the third component is the population at the start date. Each subsequent component provides the population at decade intervals. The 17-tuple is created by nesting a Tuple`3 object inside a Tuple`8 object. (That is, the Tuple`3 object is supplied as the value of the rest parameter in the Tuple`8 class constructor.) This Tuple`8 object is, in turn, nested in an outer Tuple`8 object. (That is, the Tuple`8 object is supplied as the value of the rest parameter in the outer Tuple`8 object's class constructor.)

code reference: System.Tuple.Create#19

You can retrieve the value of the tuple's first seven components by using the read-only Tuple`7.Item1, Tuple`7.Item2, Tuple`7.Item3, Tuple`7.Item4, Tuple`7.Item5, Tuple`7.Item6, and Tuple`7.Item7 instance properties. Any additional components are nested and can be retrieved from the Tuple`8.Rest property. In the previous example, the Tuple`8.Item1 through Tuple`8.Item7 properties retrieve the first through seventh components of the tuple. The eighth through fourteenth components are contained in the tuple that is nested at the second level, and are represented by the Rest.Item1 through Rest.Item7 properties. The fifteenth through seventeenth components are contained in the tuple that is nested at the third level, and are represented by the Rest.Rest.Item1 though Rest.Rest.Item3 properties.

Tuples are commonly used in four different ways:

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 4.0.0.0