语言

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

定义

返回一个字符串,表示此 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、Item2、Item3、Item4、Item5、Item6 和 Item7 分别表示属性Item1Item2Item3Item4Item5Item6Item7的值。 如果任一属性值为 null,则表示为 String.Empty。

适用于