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、Item4Item5, Item6, Item7
、) 的形式,其中 Item1、Item2、Item3、Item4、Item5、Item6 和 Item7 分别表示 、、Item2、Item5Item4Item3Item6、 和 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 |