Tuple<T1,T2,T3,T4,T5,T6>.ToString 方法

定義

傳回字串,表示這個 Tuple<T1,T2,T3,T4,T5,T6> 執行個體的值。

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

傳回

Tuple<T1,T2,T3,T4,T5,T6> 物件的字串表示。

範例

下列範例會 Tuple<T1,T2,T3,T4,T5,T6> 定義 物件,其中包含 1960 到 2000 年每個人口普查的紐約市人口資料。 然後,呼叫 方法會顯示 ToString 性別的元件。

using System;

public class Example
{
   public static void Main()
   {
      // Get population data for New York City, 1960-2000.
      var population = Tuple.Create("New York", 7781984, 7894862, 
                                    7071639, 7322564, 8008278);
      Console.WriteLine(population.ToString());
   }
}
// The example displays the following output:
//    (New York, 7781984, 7894862, 7071639, 7322564, 8008278)
open System

// Get population data for New York City, 1960-2000.
let population = Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278)
printfn $"{population.ToString()}"
// The example displays the following output:
//    (New York, 7781984, 7894862, 7071639, 7322564, 8008278)
Module Example
   Public Sub Main()
      ' Get population data for New York City, 1960-2000.
      Dim population = Tuple.Create("New York", 7781984, 7894862, 
                                    7071639, 7322564, 8008278)
      Console.WriteLine(population.ToString())                                 
   End Sub
End Module
' The example displays the following output:
'       (New York, 7781984, 7894862, 7071639, 7322564, 8008278)

備註

這個方法傳回的字串 (會採用Item1Item2Item3Item4Item5, Item6) 格式,其中Item1Item2、Item3、Item4Item5Item6分別代表 、 Item2Item3Item4Item5 、 和 Item6 屬性的值。 Item1 如果任一屬性值為 null ,則會表示為 String.Empty

適用於