Tuple(T1, T2, T3, T4, T5, T6, T7, TRest).Rest Property

Gets the current Tuple(T1, T2, T3, T4, T5, T6, T7, TRest) object's remaining components.

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

member Rest : 'TRest with get

Property Value

Type: TRest
The value of the current Tuple(T1, T2, T3, T4, T5, T6, T7, TRest) object's remaining components.

The Rest 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 Item1 through Item7 properties. You can then use the Rest property of a nested Tuple(T1, T2, T3, T4, T5, T6, T7, TRest) 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 Rest property by extracting the digit from its type name. The following example provides an illustration.

Imports System.Reflection

Module Example
    Sub Main()
        Dim from1980 As Tuple(Of Integer, Integer, Integer) =
            Tuple.Create(1203339, 1027974, 951270)
        Dim from1910 As New Tuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, _
            Tuple(Of Integer, Integer, Integer)) _
            (465766, 993078, 1568622, 1623452, 1849568, 1670144, 1511462, from1980)
        Dim population As New Tuple(Of String, Integer, Integer, Integer, Integer, Integer, Integer, _ 
            Tuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, Tuple(Of Integer, Integer, Integer))) _
            ("Detroit", 1860, 45619, 79577, 116340, 205876, 285704, from1910)

        ShowComponentCount(population)
   End Sub 

   Private Sub ShowComponentCount(tuple As Object) 
      Static ctr As Integer = 0
      Static totalComponents As Integer = 0
      Dim components As Integer = 0

      ctr += 1
      Dim name As String = tuple.GetType().Name
      components += Int32.Parse(name.Substring(name.IndexOf("`") + 1))
      If components = 8 Then
         totalComponents += 7
         Console.WriteLine("The tuple at level {0} has 7 components.", ctr)
         ShowComponentCount(tuple.Rest)
      Else
         totalComponents += components
         Console.WriteLine("The tuple at level {0} has {1} components.", 
                           ctr, components)
         Console.WriteLine("Total components in tuple: {0}", totalComponents)
      End If       
   End Sub         
End Module 
' The example displays the following output: 
'       The tuple at level 1 has 7 components. 
'       The tuple at level 2 has 7 components. 
'       The tuple at level 3 has 3 components. 
'       Total components in tuple: 17

The following example creates a 17-tuple object that contains population data for the city of Detroit, Michigan, from 1860 to 2000. The seventh component of the 17-tuple is the population in 1900. The example uses the Rest property to retrieve the values of the eighth through fourteenth components, and it uses the Rest property of the nested Tuple(T1, T2, T3, T4, T5, T6, T7, TRest) object to retrieve the values of the remaining components.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft