Tuple<T1,T2,T3>.ToString 메서드

정의

Tuple<T1,T2,T3> 인스턴스의 값을 나타내는 문자열을 반환합니다.

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

반환

Tuple<T1,T2,T3> 개체의 문자열 표현입니다.

예제

다음 예제에서는 메서드를 보여 줍니다 ToString .

using System;

public class Example
{
   public static void Main()
   {
      Tuple<string, double, int>[] scores = 
                    { Tuple.Create("Jack", 78.8, 8),
                      Tuple.Create("Abbey", 92.1, 9), 
                      Tuple.Create("Dave", 88.3, 9),
                      Tuple.Create("Sam", 91.7, 8), 
                      Tuple.Create("Ed", 71.2, 5),
                      Tuple.Create("Penelope", 82.9, 8),
                      Tuple.Create("Linda", 99.0, 9),
                      Tuple.Create("Judith", 84.3, 9) };
      Array.Sort(scores);
      foreach (var score in scores)
         Console.WriteLine(score.ToString());
   }
}
// The example displays the following output;
//    (Abbey, 92.1, 9)
//    (Dave, 88.3, 9)
//    (Ed, 71.2, 5)
//    (Jack, 78.8, 8)
//    (Judith, 84.3, 9)
//    (Linda, 99, 9)
//    (Penelope, 82.9, 8)
//    (Sam, 91.7, 8)
open System

let scores = 
    [| Tuple.Create("Jack", 78.8, 8)
       Tuple.Create("Abbey", 92.1, 9)
       Tuple.Create("Dave", 88.3, 9)
       Tuple.Create("Sam", 91.7, 8)
       Tuple.Create("Ed", 71.2, 5)
       Tuple.Create("Penelope", 82.9, 8)
       Tuple.Create("Linda", 99.0, 9)
       Tuple.Create("Judith", 84.3, 9) |] 
Array.Sort scores
for score in scores do
    printfn $"{score}"
// The example displays the following output
//    (Abbey, 92.1, 9)
//    (Dave, 88.3, 9)
//    (Ed, 71.2, 5)
//    (Jack, 78.8, 8)
//    (Judith, 84.3, 9)
//    (Linda, 99, 9)
//    (Penelope, 82.9, 8)
//    (Sam, 91.7, 8)
Module Example
   Public Sub Main()
      Dim scores() = 
                { Tuple.Create("Jack", 78.8, 8),
                  Tuple.Create("Abbey", 92.1, 9), 
                  Tuple.Create("Dave", 88.3, 9),
                  Tuple.Create("Sam", 91.7, 8), 
                  Tuple.Create("Ed", 71.2, 5),
                  Tuple.Create("Penelope", 82.9, 8),
                  Tuple.Create("Linda", 99.0, 9),
                  Tuple.Create("Judith", 84.3, 9) }
      Array.Sort(scores)
      For Each score In scores
         Console.WriteLine(score.ToString())
      Next
   End Sub
End Module
' The example displays the following output;
'    (Abbey, 92.1, 9)
'    (Dave, 88.3, 9)
'    (Ed, 71.2, 5)
'    (Jack, 78.8, 8)
'    (Judith, 84.3, 9)
'    (Linda, 99, 9)
'    (Penelope, 82.9, 8)
'    (Sam, 91.7, 8)

설명

이 메서드에서 반환된 문자열은 양식(Item1, Item2, Item3)을 사용합니다. 여기서 Item1, Item2Item3은 각각 , Item2Item3 속성의 Item1값을 나타냅니다. 속성 값이 인 null경우 로 표시됩니다 String.Empty.

적용 대상