Tuple<T1, T2, T3, T4, T5, T6, T7, TRest>.Item5 Property
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Gets the value of the current Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> object's fifth component.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public ReadOnly Property Item5 As T5
public T5 Item5 { get; }
Property Value
Type: T5
The value of the current Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> object's fifth component.
Remarks
You can dynamically determine the type of the Item5 component in one of two ways:
By calling the GetType method on the value that is returned by the Item5 property.
By retrieving the Type object that represents the Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> object, and retrieving the fifth element from the array that is returned by its Type.GetGenericArguments method.
Examples
The following example creates a 17-tuple object that contains population data for the city of Detroit, Michigan, from 1860 to 2000. The fifth component of the 17-tuple is the population in 1880. The example uses the Item5 property to display the population value and to calculate the annual rate of population change between 1880 and 1890.
Imports system.Windows.Media
Module Example
Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
outputBlock.FontFamily = new FontFamily("Courier New")
Dim from1980 = 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)
outputBlock.Text += String.Format("Population of {0}", population.Item1) & vbCrLf
outputBlock.Text &= vbCrLf
outputBlock.Text &= String.Format("{0,5} {1,14} {2,10}", "Year", "Population", "Change") & vbCrLf
Dim year As Integer = population.Item2
ShowPopulation(outputBlock, year, population.Item3)
year += 10
ShowPopulationChange(outputBlock, year, population.Item4, population.Item3)
year += 10
ShowPopulationChange(outputBlock, year, population.Item5, population.Item4)
year += 10
ShowPopulationChange(outputBlock, year, population.Item6, population.Item5)
year += 10
ShowPopulationChange(outputBlock, year, population.Item7, population.Item6)
year += 10
ShowPopulationChange(outputBlock, year, population.Rest.Item1, population.Item7)
year += 10
ShowPopulationChange(outputBlock, year, population.Rest.Item2, population.Rest.Item1)
year += 10
ShowPopulationChange(outputBlock, year, population.Rest.Item3, population.Rest.Item2)
year += 10
ShowPopulationChange(outputBlock, year, population.Rest.Item4, population.Rest.Item3)
year += 10
ShowPopulationChange(outputBlock, year, population.Rest.Item5, population.Rest.Item4)
year += 10
ShowPopulationChange(outputBlock, year, population.Rest.Item6, population.Rest.Item5)
year += 10
ShowPopulationChange(outputBlock, year, population.Rest.Item7, population.Rest.Item6)
year += 10
ShowPopulationChange(outputBlock, year, population.Rest.Rest.Item1, population.Rest.Item7)
year += 10
ShowPopulationChange(outputBlock, year, population.Rest.Rest.Item2, population.Rest.Rest.Item1)
year += 10
ShowPopulationChange(outputBlock, year, population.Rest.Rest.Item3, population.Rest.Rest.Item2)
End Sub
Private Sub ShowPopulationChange(ByVal outputBlock As System.Windows.Controls.TextBlock, ByVal year As Integer, ByVal newPopulation As Integer, ByVal oldPopulation As Integer)
outputBlock.Text += String.Format("{0,5} {1,14:N0} {2,10:P2}", year, newPopulation, _
(newPopulation - oldPopulation) / oldPopulation / 10) & vbCrLf
End Sub
Private Sub ShowPopulation(ByVal outputBlock As System.Windows.Controls.TextBlock, ByVal year As Integer, ByVal newPopulation As Integer)
outputBlock.Text += String.Format("{0,5} {1,14:N0} {2,10:P2}", year, newPopulation, "n/a") & vbCrLf
End Sub
End Module
' The example displays the following output:
'
' Population of Detroit
' Year Population Change
' 1860 45,619 n/a
' 1870 79,577 7.44 %
' 1880 116,340 4.62 %
' 1890 205,876 7.70 %
' 1900 285,704 3.88 %
' 1910 465,766 6.30 %
' 1920 993,078 11.32 %
' 1930 1,568,622 5.80 %
' 1940 1,623,452 0.35 %
' 1950 1,849,568 1.39 %
' 1960 1,670,144 -0.97 %
' 1970 1,511,462 -0.95 %
' 1980 1,203,339 -2.04 %
' 1990 1,027,974 -1.46 %
' 2000 951,270 -0.75 %
using System;
using System.Windows.Media;
class Example
{
public static void Demo(System.Windows.Controls.TextBlock outputBlock)
{
outputBlock.FontFamily = new FontFamily("Courier New");
Tuple<int, int, int> from1980 = Tuple.Create(1203339, 1027974, 951270);
var from1910 = new Tuple<int, int, int, int, int, int, int, Tuple<int, int, int>>
(465766, 993078, 1568622, 1623452, 1849568, 1670144, 1511462, from1980);
var population = new Tuple<string, int, int, int, int, int, int,
Tuple<int, int, int, int, int, int, int, Tuple<int, int, int>>>
("Detroit", 1860, 45619, 79577, 116340, 205876, 285704, from1910);
outputBlock.Text += String.Format("Population of {0}\n\n", population.Item1);
outputBlock.Text += String.Format("{0,5} {1,14} {2,10}\n", "Year", "Population", "Change");
int year = population.Item2;
ShowPopulation(outputBlock, year, population.Item3);
year += 10;
ShowPopulationChange(outputBlock, year, population.Item4, population.Item3);
year += 10;
ShowPopulationChange(outputBlock, year, population.Item5, population.Item4);
year += 10;
ShowPopulationChange(outputBlock, year, population.Item6, population.Item5);
year += 10;
ShowPopulationChange(outputBlock, year, population.Item7, population.Item6);
year += 10;
ShowPopulationChange(outputBlock, year, population.Rest.Item1, population.Item7);
year += 10;
ShowPopulationChange(outputBlock, year, population.Rest.Item2, population.Rest.Item1);
year += 10;
ShowPopulationChange(outputBlock, year, population.Rest.Item3, population.Rest.Item2);
year += 10;
ShowPopulationChange(outputBlock, year, population.Rest.Item4, population.Rest.Item3);
year += 10;
ShowPopulationChange(outputBlock, year, population.Rest.Item5, population.Rest.Item4);
year += 10;
ShowPopulationChange(outputBlock, year, population.Rest.Item6, population.Rest.Item5);
year += 10;
ShowPopulationChange(outputBlock, year, population.Rest.Item7, population.Rest.Item6);
year += 10;
ShowPopulationChange(outputBlock, year, population.Rest.Rest.Item1, population.Rest.Item7);
year += 10;
ShowPopulationChange(outputBlock, year, population.Rest.Rest.Item2, population.Rest.Rest.Item1);
year += 10;
ShowPopulationChange(outputBlock, year, population.Rest.Rest.Item3, population.Rest.Rest.Item2);
}
private static void ShowPopulationChange(System.Windows.Controls.TextBlock outputBlock, int year, int newPopulation, int oldPopulation)
{
outputBlock.Text += String.Format("{0,5} {1,14:N0} {2,10:P2}", year, newPopulation,
((double)(newPopulation - oldPopulation) / oldPopulation) / 10) + "\n";
}
private static void ShowPopulation(System.Windows.Controls.TextBlock outputBlock, int year, int newPopulation)
{
outputBlock.Text += String.Format("{0,5} {1,14:N0} {2,10:P2}", year, newPopulation, "n/a") + "\n";
}
}
// The example displays the following output:
//
// Population of Detroit
// Year Population Change
// 1860 45,619 n/a
// 1870 79,577 7.44 %
// 1880 116,340 4.62 %
// 1890 205,876 7.70 %
// 1900 285,704 3.88 %
// 1910 465,766 6.30 %
// 1920 993,078 11.32 %
// 1930 1,568,622 5.80 %
// 1940 1,623,452 0.35 %
// 1950 1,849,568 1.39 %
// 1960 1,670,144 -0.97 %
// 1970 1,511,462 -0.95 %
// 1980 1,203,339 -2.04 %
// 1990 1,027,974 -1.46 %
// 2000 951,270 -0.75 %
Version Information
Silverlight
Supported in: 5, 4
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.