Tuple<T1,T2,T3,T4,T5,T6,T7>.ToString 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳一個字串,代表該 Tuple<T1,T2,T3,T4,T5,T6,T7> 實例的值。
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,T7> 字串表示。
範例
以下範例定義了一個 Tuple<T1,T2,T3,T4,T5,T6,T7> 物件,該物件包含1950年至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", 7891957, 7781984,
7894862, 7071639, 7322564, 8008278);
Console.WriteLine(population.ToString());
}
}
// The example displays the following output:
// (New York, 7891957, 7781984, 7894862, 7071639, 7322564, 8008278)
open System
// Get population data for New York City, 1960-2000.
let population =
Tuple.Create("New York", 7891957, 7781984, 7894862, 7071639, 7322564, 8008278)
printfn $"{population}"
// The example displays the following output:
// (New York, 7891957, 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", 7891957, 7781984,
7894862, 7071639, 7322564, 8008278)
Console.WriteLine(population.ToString())
End Sub
End Module
' The example displays the following output:
' (New York, 7891957, 7781984, 7894862, 7071639, 7322564, 8008278)
備註
此方法回傳的字串形式為 (Item1, Item2, Item3, Item4, Item5, Item6, Item7), 其中 Item1, Item2, Item3, Item4, Item5, Item6 和 Item7 分別代表 , Item1, Item2Item3Item4Item5和 Item6 屬性的Item7值。 若任一性質值為 null,則表示為 String.Empty。