当前位置: 首页>>代码示例>>C#>>正文


C# Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>.Item2属性代码示例

本文整理汇总了C#中System.Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>.Item2属性的典型用法代码示例。如果您正苦于以下问题:C# Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>.Item2属性的具体用法?C# Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>.Item2怎么用?C# Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>.Item2使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>的用法示例。


在下文中一共展示了Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>.Item2属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

//引入命名空间
using System;

class Example
{
    static void Main(string[] args)
    {
        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);

        Console.WriteLine("Population of {0}", population.Item1);
        Console.WriteLine();
        Console.WriteLine("{0,5}  {1,14}  {2,10}", "Year", "Population", "Change");

        int year = population.Item2;
        ShowPopulation(year, population.Item3);
        year += 10;
        ShowPopulationChange(year, population.Item4, population.Item3);
        year += 10;
        ShowPopulationChange(year, population.Item5, population.Item4);
        year += 10;
        ShowPopulationChange(year, population.Item6, population.Item5);
        year += 10;
        ShowPopulationChange(year, population.Item7, population.Item6);
        year += 10;
        ShowPopulationChange(year, population.Rest.Item1, population.Item7);
        year += 10;
        ShowPopulationChange(year, population.Rest.Item2, population.Rest.Item1);
        year += 10;
        ShowPopulationChange(year, population.Rest.Item3, population.Rest.Item2);
        year += 10;
        ShowPopulationChange(year, population.Rest.Item4, population.Rest.Item3);
        year += 10;
        ShowPopulationChange(year, population.Rest.Item5, population.Rest.Item4);
        year += 10;
        ShowPopulationChange(year, population.Rest.Item6, population.Rest.Item5);
        year += 10;
        ShowPopulationChange(year, population.Rest.Item7, population.Rest.Item6);
        year += 10;
        ShowPopulationChange(year, population.Rest.Rest.Item1, population.Rest.Item7);
        year += 10;
        ShowPopulationChange(year, population.Rest.Rest.Item2, population.Rest.Rest.Item1);
        year += 10;
        ShowPopulationChange(year, population.Rest.Rest.Item3, population.Rest.Rest.Item2);
    }

    private static void ShowPopulationChange(int year, int newPopulation, int oldPopulation)
    {
        Console.WriteLine("{0,5}  {1,14:N0}  {2,10:P2}", year, newPopulation,
                          ((double)(newPopulation - oldPopulation) / oldPopulation) / 10);
    }

    private static void ShowPopulation(int year, int newPopulation)
    {
        Console.WriteLine("{0,5}  {1,14:N0}  {2,10:P2}", year, newPopulation, "n/a");
    }
}
开发者ID:.NET开发者,项目名称:System,代码行数:61,代码来源:Tuple.Item2

输出:

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 %


注:本文中的System.Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>.Item2属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。