Share via


Tuple<T1,T2,T3,T4,T5>.ToString Yöntem

Tanım

Bu Tuple<T1,T2,T3,T4,T5> örneğin değerini temsil eden bir dize döndürür.

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

Döndürülenler

Bu Tuple<T1,T2,T3,T4,T5> nesnenin dize gösterimi.

Örnekler

Aşağıdaki örnekte yöntemi gösterilmektedir ToString . Birleşik Devletler bir durumun adını, 1990 ve 2000'deki popülasyonunu, bu 10 yıllık dönemdeki nüfus değişikliğini ve yıllık nüfus değişikliği oranını içeren 5 tanımlama grubu nesnelerinin bir dizisini görüntüler.

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)

Açıklamalar

Bu yöntem tarafından döndürülen dize forma (Item1, Item2, Item3, Item4), Item5burada Item1, Item2, Item3, Item4 biçimindedir ve Item5 sırasıyla , Item2, Item3, Item4ve Item5 özelliklerinin değerlerini Item1temsil eder. Özellik değerlerinden herhangi biri ise null, olarak String.Emptytemsil edilir.

Şunlara uygulanır