Tuple<T1,T2,T3,T4,T5>.ToString Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Returnerar en sträng som representerar värdet för den här Tuple<T1,T2,T3,T4,T5> instansen.
public:
override System::String ^ ToString();
public override string ToString();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
Returer
Strängrepresentationen av det här Tuple<T1,T2,T3,T4,T5> objektet.
Exempel
I följande exempel visas ToString metoden. Den visar en matris med 5 tupppelobjekt som innehåller namnet på ett tillstånd i United States, dess befolkning 1990 och 2000, dess befolkningsförändring under den här tioårsperioden och den årliga befolkningsförändringen.
using System;
public class Example
{
public static void Main()
{
// Define array of tuples reflecting population change by state, 1990-2000.
Tuple<string, int, int, int, double>[] populationChanges =
{ Tuple.Create("California", 29760021, 33871648, 4111627, 13.8),
Tuple.Create("Illinois", 11430602, 12419293, 988691, 8.6),
Tuple.Create("Washington", 4866692, 5894121, 1027429, 21.1) };
// Display each tuple.
foreach (var item in populationChanges)
Console.WriteLine(item.ToString());
}
}
// The example displays the following output:
// (California, 29760021, 33871648, 4111627, 13.8)
// (Illinois, 11430602, 12419293, 988691, 8.6)
// (Washington, 4866692, 5894121, 1027429, 21.1)
open System
// Define array of tuples reflecting population change by state, 1990-2000.
let populationChanges =
[| Tuple.Create("California", 29760021, 33871648, 4111627, 13.8)
Tuple.Create("Illinois", 11430602, 12419293, 988691, 8.6)
Tuple.Create("Washington", 4866692, 5894121, 1027429, 21.1) |]
// Display each tuple.
for item in populationChanges do
printfn $"{item.ToString()}"
// The example displays the following output:
// (California, 29760021, 33871648, 4111627, 13.8)
// (Illinois, 11430602, 12419293, 988691, 8.6)
// (Washington, 4866692, 5894121, 1027429, 21.1)
Module Example
Public Sub Main()
' Define array of tuples reflecting population change by state, 1990-2000.
Dim populationChanges() =
{ Tuple.Create("California", 29760021, 33871648, 4111627, 13.8),
Tuple.Create("Illinois", 11430602, 12419293, 988691, 8.6),
Tuple.Create("Washington", 4866692, 5894121, 1027429, 21.1) }
' Display each tuple.
For Each item In populationChanges
Console.WriteLine(item.ToString())
Next
End Sub
End Module
' The example displays the following output:
' (California, 29760021, 33871648, 4111627, 13.8)
' (Illinois, 11430602, 12419293, 988691, 8.6)
' (Washington, 4866692, 5894121, 1027429, 21.1)
Kommentarer
Strängen som returneras av den här metoden tar formuläret (Item1, Item2, Item3, Item4, Item5), där Item1, Item2, Item3, Item4 och Item5 representerar värdena Item1för egenskaperna , Item2, Item3, Item4respektive Item5 . Om något av egenskapsvärdena är nullrepresenteras det som String.Empty.