Tuple<T1,T2,T3,T4,T5>.ToString Méthode

Définition

Retourne une chaîne qui représente la valeur de cette instance Tuple<T1,T2,T3,T4,T5>.

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

Retours

Représentation sous forme de chaîne de cet objet Tuple<T1,T2,T3,T4,T5>.

Exemples

L’exemple suivant illustre la ToString méthode . Il affiche un tableau d’objets de 5 tuples qui contiennent le nom d’un état dans l’États-Unis, sa population en 1990 et 2000, son changement de population au cours de cette période de 10 ans et le taux annuel de variation de la population.

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)

Remarques

La chaîne retournée par cette méthode prend la forme (Item1, Item2, Item3, Item4, Item5), où Item1, Item2, Item3, Item4 et Item5 représentent respectivement les valeurs des Item1propriétés , Item2, Item3, Item4, et Item5 . Si l’une des valeurs de propriété est null, elle est représentée sous la forme String.Empty.

S’applique à