mscorlib 4.0.0.0 System.Object System.Collections.IStructuralComparable System.Collections.IStructuralEquatable System.IComparable System.ITuple To be added. To be added. To be added. To be added. To be added. To be added. To be added. To be added.

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

You can instantiate a object with exactly eight components by calling the static 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 constructor. The following example uses the constructor to create an 8-tuple that is equivalent to the tuple created in the previous example.

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

To create an n-tuple with nine or more components, you must call the constructor. The static factory methods of the 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 constructor, you supply a generic Tuple object as the 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 object inside a object. (That is, the object is supplied as the value of the parameter in the class constructor.) This object is, in turn, nested in an outer object. (That is, the object is supplied as the value of the parameter in the outer 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 , , , , , , and instance properties. Any additional components are nested and can be retrieved from the property. In the previous example, the through 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 object.

To pass multiple values to a method through a single parameter. For example, the method has a single parameter that lets you supply one value to the method that the thread executes at startup. If you supply a object as the method argument, you can supply the thread’s startup routine with seven items of data.

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

- Constructor
  4.0.0.0
  To be added.
  To be added.
  To be added.
  To be added.
  To be added.
  To be added.
  To be added.
  To be added.
  To be added.
  To be added.
- Method
  4.0.0.0
  System.Boolean ``

  The parameter is considered to be equal to the current instance if it meets all the following conditions:

  It is a object.

  It has the same total number of components that are of the same types as the current instance.

  Its components (including its nested components) are equal to those of the current instance. Equality is determined by the default equality comparer for each component.

  Returns a value that indicates whether the current object is equal to a specified object.

  true if the current instance is equal to the specified object; otherwise, false.

  The object to compare with this instance.
- Method
  4.0.0.0
  System.Int32 To be added.

  Calculates the hash code for the current object.

  A 32-bit signed integer hash code.

- Property
  4.0.0.0
  T1 To be added.

  You can dynamically determine the type of the component in one of two ways:

  By calling the GetType method on the value that is returned by the property.

  By retrieving the object that represents the object, and retrieving the first element from the array that is returned by its method.

  Gets the value of the current object's first component.

- Property
  4.0.0.0
  T2 To be added.

  You can dynamically determine the type of the component in one of two ways:

  By calling the GetType method on the value that is returned by the property.

  By retrieving the object that represents the object, and retrieving the second element from the array that is returned by its method.

  Gets the value of the current object's second component.

- Property
  4.0.0.0
  T3 To be added.

  You can dynamically determine the type of the component in one of two ways:

  By calling the GetType method on the value that is returned by the property.

  By retrieving the object that represents the object, and retrieving the third element from the array that is returned by its method.

  Gets the value of the current object's third component.

- Property
  4.0.0.0
  T4 To be added.

  You can dynamically determine the type of the component in one of two ways:

  By calling the GetType method on the value that is returned by the property.

  By retrieving the object that represents the object, and retrieving the fourth element from the array that is returned by its method.

  Gets the value of the current object's fourth component.

- Property
  4.0.0.0
  T5 To be added.

  You can dynamically determine the type of the component in one of two ways:

  By calling the GetType method on the value that is returned by the property.

  By retrieving the object that represents the object, and retrieving the fifth element from the array that is returned by its method.

  Gets the value of the current object's fifth component.

- Property
  4.0.0.0
  T6 To be added.

  You can dynamically determine the type of the component in one of two ways:

  By calling the GetType method on the value that is returned by the property.

  By retrieving the object that represents the object, and retrieving the sixth element from the array that is returned by its method.

  Gets the value of the current object's sixth component.

- Property
  4.0.0.0
  T7 To be added.

  You can dynamically determine the type of the component in one of two ways:

  By calling the GetType method on the value that is returned by the property.

  By retrieving the object that represents the object, and retrieving the seventh element from the array that is returned by its method.

  Gets the value of the current object's seventh component.

- Property
  4.0.0.0
  TRest To be added.

  The property returns a nested Tuple object that allows access to the eighth though nth components of the tuple. Depending on the total number of components in the tuple, the values of the eighth through fourteenth components can be retrieved from the nested Tuple object's through properties. You can then use the property of a nested object to retrieve the Tuple object at the next level of nesting.

  You can dynamically determine the number of components in a nested Tuple object that is returned by the property by extracting the digit from its type name. The following example provides an illustration.

  code reference: System.Tuple`8.Item1#2

  Gets the current object's remaining components.

- Method
  4.0.0.0
  System.Int32 `` ``

  This member is an explicit interface implementation. It can be used only when the instance is cast to an interface.

  This method lets you define customized comparisons of objects. For example, you can use this method to order objects based on the value of a specific component.

  Although this method can be called directly, it is most commonly called by collection-sorting methods that include parameters to order the members of a collection. For example, it is called by the method and the method of a object that is instantiated by using the constructor.

  The method is intended for use in sorting operations. It should not be used when the primary purpose of a comparison is to determine whether two objects are equal. To determine whether two objects are equal, call the method.

  Compares the current 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.

  A signed integer that indicates the relative position of this instance and in the sort order, as shown in the following table.

  Value

  Description

  A negative integer

  This instance precedes .

  Zero

  This instance and have the same position in the sort order.

  A positive integer

  This instance follows .

  An object to compare with the current instance. An object that provides custom rules for comparison.
- Method
  4.0.0.0
  System.Boolean `` ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface.

  The implementation is called only if is not null, and if it can be successfully cast (in C#) or converted (in Visual Basic) to a object that has the same total number of components (including those in nested Tuple objects) of the same types as the current instance. The method first passes the values of the objects to be compared to the implementation. If this method call returns true, the method is called again and passed the values of the two objects. This continues until the method call returns false when it compares a specific pair of values, or the two values are passed to the method.

  Returns a value that indicates whether the current object is equal to a specified object based on a specified comparison method.

  true if the current instance is equal to the specified object; otherwise, false.

  The object to compare with this instance. An object that defines the method to use to evaluate whether the two objects are equal.
- Method
  4.0.0.0
  System.Int32 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface.

  The method simply wraps a call to the object's implementation.

  The algorithm used to compute the hash code should return the same hash code for two objects that are considered to be equal.

  Calculates the hash code for the current object by using a specified computation method.

  A 32-bit signed integer hash code.

  An object whose method calculates the hash code of the current object.
- Method
  4.0.0.0
  System.Int32 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface.

  This method provides the implementation for the class. Although the method can be called directly, it is most commonly called by the default overloads of collection-sorting methods, such as and , to order the members of a collection.

  The method is intended for use in sorting operations. It should not be used when the primary purpose of a comparison is to determine whether two objects are equal. To determine whether two objects are equal, call the method.

  This method uses the default object comparer to compare each component.

  Compares the current 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.

  A signed integer that indicates the relative position of this instance and in the sort order, as shown in the following table.

  Value

  Description

  A negative integer

  This instance precedes .

  Zero

  This instance and have the same position in the sort order.

  A positive integer

  This instance follows .

  An object to compare with the current instance.
- Method
  4.0.0.0
  System.String To be added. To be added. To be added.
- Method
  4.0.0.0
  System.String

  The string returned by this method takes the form (Item1, Item2, Item3, Item4, , Item8…), where Item1, Item2, Item3, Item4, Item5, Item6, and Item7 represent the values of the , , , , , , and properties. Item8 represents the value of the object's Next.Item1 property. The value of any additional nested components follow Item8. If any of the property values is null, it is represented as .

  Returns a string that represents the value of this instance.

  The string representation of this object.