Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) Class

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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

Inheritance Hierarchy

System..::.Object
System..::.Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>)

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

Syntax

Public Class Tuple(Of T1, T2, T3, T4, T5, T6, T7, TRest) _
    Implements IStructuralComparable, IStructuralEquatable, IComparable
public class Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> : IStructuralComparable, 
    IStructuralEquatable, IComparable

Type Parameters

  • T1
    The type of the tuple's first component.
  • T2
    The type of the tuple's second component.
  • T3
    The type of the tuple's third component.
  • T4
    The type of the tuple's fourth component.
  • T5
    The type of the tuple's fifth component.
  • T6
    The type of the tuple's sixth component.
  • T7
    The type of the tuple's seventh component.
  • TRest
    Any generic Tuple object that defines the types of the tuple's remaining components.

The Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) type exposes the following members.

Constructors

Name Description
Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) Initializes a new instance of the Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) class.

Top

Properties

Name Description
Item1 Gets the value of the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object's first component.
Item2 Gets the value of the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object's second component.
Item3 Gets the value of the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object's third component.
Item4 Gets the value of the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object's fourth component.
Item5 Gets the value of the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object's fifth component.
Item6 Gets the value of the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object's sixth component.
Item7 Gets the value of the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object's seventh component.
Rest Gets the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object's remaining components.

Top

Methods

Name Description
Equals Returns a value that indicates whether the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object is equal to a specified object. (Overrides Object..::.Equals(Object).)
Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
GetHashCode Calculates the hash code for the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object. (Overrides Object..::.GetHashCode()()().)
GetType Gets the Type of the current instance. (Inherited from Object.)
MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
ToString Returns a string that represents the value of this Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) instance. (Overrides Object..::.ToString()()().)

Top

Explicit Interface Implementations

Name Description
IComparable..::.CompareTo Compares the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object to a specified object and returns an integer that indicates whether the current object is before, after, or in the same position as the specified object in the sort order.
IStructuralComparable..::.CompareTo Compares the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object to a specified object by using a specified comparer and returns an integer that indicates whether the current object is before, after, or in the same position as the specified object in the sort order.
IStructuralEquatable..::.Equals Returns a value that indicates whether the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object is equal to a specified object based on a specified comparison method.
IStructuralEquatable..::.GetHashCode Calculates the hash code for the current Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object by using a specified computation method.

Top

Remarks

A tuple is a data structure that has a specific number and sequence of values. The Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) class represents an n-tuple that has eight or more components.

You can instantiate a Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object with exactly eight components by calling the static Tuple..::.Create 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.

You can also instantiate an n-tuple object with eight or more components by calling the Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) constructor. The following example uses the Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) constructor to create an 8-tuple that is equivalent to the tuple created in the previous example.

Note

To create an n-tuple with nine or more components, you must call the Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) 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<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) 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<(Of <(T1, T2, T3>)>) object inside a Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object. (That is, the Tuple<(Of <(T1, T2, T3>)>) object is supplied as the value of the rest parameter in the Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) class constructor.) This Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object is, in turn, nested in an outer Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object. (That is, the Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object is supplied as the value of the rest parameter in the outer Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7, TRest>)>) object's class constructor.)

You can retrieve the value of the tuple's first seven components by using the read-only Item1, Item2, Item3, Item4, Item5, Item6, and Item7 instance properties. Any additional components are nested and can be retrieved from the Rest property. In the previous example, the Item1 through 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:

  • To represent a single set of data. For example, a tuple can represent a database record, and its components can represent individual fields of the record.

  • To provide easy access to, and manipulation of, a data set.

  • To return multiple values from a method without the use of out parameters (in C#) or ByRef parameters (in Visual Basic). For example, the previous example returns its computed statistics, along with the city name, in a Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7>)>) object.

  • To pass multiple values to a method through a single parameter. For example, the Thread..::.Start(Object) method has a single parameter that lets you supply one value to the method that the thread executes at startup. If you supply a Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7>)>) object as the method argument, you can supply the thread’s startup routine with seven items of data.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System Namespace

Tuple

Tuple<(Of <(T1>)>)

Tuple<(Of <(T1, T2>)>)

Tuple<(Of <(T1, T2, T3>)>)

Tuple<(Of <(T1, T2, T3, T4>)>)

Tuple<(Of <(T1, T2, T3, T4, T5>)>)

Tuple<(Of <(T1, T2, T3, T4, T5, T6>)>)

Tuple<(Of <(T1, T2, T3, T4, T5, T6, T7>)>)