Tuple<T1,T2>.ToString 메서드

정의

Tuple<T1,T2> 인스턴스의 값을 나타내는 문자열을 반환합니다.Returns a string that represents the value of this Tuple<T1,T2> instance.

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

반환

Tuple<T1,T2> 개체의 문자열 표현입니다.The string representation of this Tuple<T1,T2> object.

예제

다음 예제에서는 ToString 메서드를 보여 줍니다.The following example illustrates the ToString method.

using System;

public class Class1
{
   public static void Main()
   {
      Tuple<string, Nullable<int>>[] scores = 
                      { new Tuple<string, Nullable<int>>("Abbey", 92), 
                        new Tuple<string, Nullable<int>>("Dave", 88),
                        new Tuple<string, Nullable<int>>("Ed", null),
                        new Tuple<string, Nullable<int>>("Jack", 78),
                        new Tuple<string, Nullable<int>>("Linda", 99),
                        new Tuple<string, Nullable<int>>("Judith", 84), 
                        new Tuple<string, Nullable<int>>("Penelope", 82),
                        new Tuple<string, Nullable<int>>("Sam", 91) }; 
      foreach (var score in scores)
         Console.WriteLine(score.ToString());
   }
}
// The example displays the following output:
//       (Abbey, 92)
//       (Dave, 88)
//       (Ed, )
//       (Jack, 78)
//       (Linda, 99)
//       (Judith, 84)
//       (Penelope, 82)
//       (Sam, 91)
Module modMain
   Public Sub Main()
      Dim scores() As Tuple(Of String, Nullable(Of Integer)) = 
                      { New Tuple(Of String, Nullable(Of Integer))("Abbey", 92), 
                        New Tuple(Of String, Nullable(Of Integer))("Dave", 88),
                        New Tuple(Of String, Nullable(Of Integer))("Ed", Nothing),                        New Tuple(Of String, Nullable(Of Integer))("Jack", 78),
                        New Tuple(Of String, Nullable(Of Integer))("Linda", 99),
                        New Tuple(Of String, Nullable(Of Integer))("Judith", 84), 
                        New Tuple(Of String, Nullable(Of Integer))("Penelope", 82),
                        New Tuple(Of String, Nullable(Of Integer))("Sam", 91) } 
      For Each score In scores
         Console.WriteLine(score.ToString())
      Next                        
   End Sub
End Module
' The example displays the following output:
'       (Abbey, 92)
'       (Dave, 88)
'       (Ed, )
'       (Jack, 78)
'       (Linda, 99)
'       (Judith, 84)
'       (Penelope, 82)
'       (Sam, 91)

설명

이 메서드에서 반환 되는 문자열은 (Item1, Item2) 형식을 사용 합니다. 여기서 Item1Item2Item1 값을 나타내고는 속성을 Item2 합니다.The string returned by this method takes the form (Item1, Item2), where Item1 and Item2 represent the values of the Item1 and Item2 properties. 두 속성 값이 null되 면 String.Empty로 표시 됩니다.If either property value is null, it is represented as String.Empty.

적용 대상