다음을 통해 공유


Tuple<T1,T2,T3,T4,T5,T6,T7>.Item1 속성

정의

현재 Tuple<T1,T2,T3,T4,T5,T6,T7> 개체의 첫 번째 구성 요소 값을 가져옵니다.

public:
 property T1 Item1 { T1 get(); };
public T1 Item1 { get; }
member this.Item1 : 'T1
Public ReadOnly Property Item1 As T1

속성 값

T1

현재 Tuple<T1,T2,T3,T4,T5,T6,T7> 개체의 첫 번째 구성 요소 값입니다.

예제

다음 예제에서는 구성 요소에 Tuple<T1,T2,T3,T4,T5,T6,T7> 1950년부터 2000년까지 미국 3개 도시(뉴욕, 시카고 및 로스앤젤레스)에 대한 인구 데이터가 포함된 개체 배열을 정의합니다. 그런 다음 데이터를 나열하는 테이블을 표시합니다. 도시 이름을 표시하기 위해 각 Tuple<T1,T2,T3,T4,T5,T6,T7> 개체에 대한 속성 값을 Item1 검색합니다.

using System;
using System.Text.RegularExpressions;

public class Class1
{
   public static void Main()
   {
      // Create tuples containing population data for New York, Chicago, 
      // and Los Angeles, 1960-2000.
      Tuple<string, int, int, int, int, int, int>[] cities =
           { Tuple.Create("New York", 7891957, 7781984, 7894862, 7071639, 7322564, 8008278),
             Tuple.Create("Los Angeles", 1970358, 2479015, 2816061, 2966850, 3485398, 3694820),
             Tuple.Create("Chicago", 3620962, 3550904, 3366957, 3005072, 2783726, 2896016) };

      // Display tuple data in table.
      string header = "Population in";
      Console.WriteLine("{0,-12} {1,66}", 
                        "City", new String('-',(66-header.Length)/2) + header + 
                                new String('-', (66-header.Length)/2));
      Console.WriteLine("{0,24}{1,11}{2,11}{3,11}{4,11}{5,11}\n", 
                        "1950", "1960", "1970", "1980", "1990", "2000");         

      foreach (var city in cities)                      
         Console.WriteLine("{0,-12} {1,11:N0}{2,11:N0}{3,11:N0}{4,11:N0}{5,11:N0}{6,11:N0}", 
                           city.Item1, city.Item2, city.Item3, city.Item4, 
                           city.Item5, city.Item6, city.Item7);
   }
}
// The example displays the following output:
//   City          --------------------------Population in--------------------------
//                       1950       1960       1970       1980       1990       2000
//
//   New York       7,891,957  7,781,984  7,894,862  7,071,639  7,322,564  8,008,278
//   Los Angeles    1,970,358  2,479,015  2,816,061  2,966,850  3,485,398  3,694,820
//   Chicago        3,620,962  3,550,904  3,366,957  3,005,072  2,783,726  2,896,016
open System

// Create tuples containing population data for New York, Chicago, 
// and Los Angeles, 1960-2000.
let cities =
    [| Tuple.Create("New York", 7891957, 7781984, 7894862, 7071639, 7322564, 8008278)
       Tuple.Create("Los Angeles", 1970358, 2479015, 2816061, 2966850, 3485398, 3694820)
       Tuple.Create("Chicago", 3620962, 3550904, 3366957, 3005072, 2783726, 2896016) |]

// Display tuple data in table.
let header = "Population in"
printfn $"""{"City",-12} {String('-',(66 - header.Length) / 2) + header + String('-', (66 - header.Length) / 2),66}""" 
printfn "%24s%11s%11s%11s%11s%11s\n" "1950" "1960" "1970" "1980" "1990" "2000"         

for city in cities do
    printfn $"{city.Item1,-12} {city.Item2,11:N0}{city.Item3,11:N0}{city.Item4,11:N0}{city.Item5,11:N0}{city.Item6,11:N0}{city.Item7,11:N0}"
// The example displays the following output:
//   City          --------------------------Population in--------------------------
//                       1950       1960       1970       1980       1990       2000
//
//   New York       7,891,957  7,781,984  7,894,862  7,071,639  7,322,564  8,008,278
//   Los Angeles    1,970,358  2,479,015  2,816,061  2,966,850  3,485,398  3,694,820
//   Chicago        3,620,962  3,550,904  3,366,957  3,005,072  2,783,726  2,896,016
Module Example
   Public Sub Main()
      ' Create tuples containing population data for New York, Chicago, 
      ' and Los Angeles, 1960-2000.
      Dim cities() =
           { Tuple.Create("New York", 7891957, 7781984, 7894862, 
                          7071639, 7322564, 8008278),
             Tuple.Create("Los Angeles", 1970358, 2479015, 2816061, 
                          2966850, 3485398, 3694820),
             Tuple.Create("Chicago", 3620962, 3550904, 3366957, 
                          3005072, 2783726, 2896016) }

      ' Display tuple data in table.
      Dim header As String = "Population in"
      Console.WriteLine("{0,-12} {1,66}", 
                        "City", New String("-"c,(66-header.Length)\2) + header + _
                                New String("-"c, (66-header.Length)\2))
      Console.WriteLine("{0,24}{1,11}{2,11}{3,11}{4,11}{5,11}", 
                        "1950", "1960", "1970", "1980", "1990", "2000")                  
      Console.WriteLine()
      For Each city In cities                      
         Console.WriteLine("{0,-12} {1,11:N0}{2,11:N0}{3,11:N0}{4,11:N0}{5,11:N0}{6,11:N0}", 
                           city.Item1, city.Item2, city.Item3, city.Item4, 
                           city.Item5, city.Item6, city.Item7)
      Next
   End Sub
End Module
' The example displays the following output:
'    City          --------------------------Population in--------------------------
'                        1950       1960       1970       1980       1990       2000
'    
'    New York       7,891,957  7,781,984  7,894,862  7,071,639  7,322,564  8,008,278
'    Los Angeles    1,970,358  2,479,015  2,816,061  2,966,850  3,485,398  3,694,820
'    Chicago        3,620,962  3,550,904  3,366,957  3,005,072  2,783,726  2,896,016

설명

다음 두 가지 방법 중 하나로 구성 요소의 형식을 Item1 동적으로 확인할 수 있습니다.

적용 대상