C# Tuple ToString

Description

Tuple ToString returns a string that represents the value of this Tuple instance.

Syntax

Tuple<T1, T2>.ToString has the following syntax.


public override string ToString()

Returns

Tuple<T1, T2>.ToString method returns The string representation of this Tuple<T1, T2> object.

Example

The following example illustrates the ToString method.


/*  w ww  . jav  a  2  s.  com*/
using System;

public class Class1
{
   public static void Main()
   {
      Tuple<string, Nullable<int>>[] scores = 
                      { new Tuple<string, Nullable<int>>("A", 2), 
                        new Tuple<string, Nullable<int>>("B", 8),
                        new Tuple<string, Nullable<int>>("C", null),
                        new Tuple<string, Nullable<int>>("D", 1) }; 
      foreach (var score in scores)
         Console.WriteLine(score.ToString());
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version