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

定义

返回表示此 Tuple<T1,T2,T3,T4,T5,T6,T7> 实例的值的字符串。

public override string ToString();

返回

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)

注解

此方法返回的字符串采用 (Item1Item2Item3Item4Item5, Item6, Item7、) 的形式,其中 Item1Item2Item3Item4Item5Item6Item7 分别表示 、、Item2Item5Item4Item3Item6、 和 Item7 属性的值。Item1 如果任一属性值为 null,则表示为 String.Empty

适用于

产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0