C# Tuple Tuple

Description

Tuple Tuple initializes a new instance of the Tuple class.

Syntax

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


public Tuple(
  T1 item1,
  T2 item2
)

Parameters

Tuple<T1, T2>.Tuple<T1, T2> has the following parameters.

  • item1 - The value of the tuple's first component.
  • item2 - The value of the tuple's second component.

Example


/*ww  w .j ava 2s.c  o m*/
using System;
public class MainClass{
  public static void Main(String[] argv){  
    var tuple2 = Tuple.Create("New York", 32.68);
    Console.WriteLine("{0}: {1}", tuple2.Item1, tuple2.Item2);
    
    
    tuple2 = new Tuple<string, double>("New York", 32.68);
    Console.WriteLine("{0}: {1}", tuple2.Item1, tuple2.Item2);

  }
}
    

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