C# Tuple Tuple

Description

Tupleinitializes a new instance of the Tuple class.

Syntax

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


public Tuple(
  T1 item1
)

Parameters

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

  • item1 - The value of the tuple's only component.

Example

The following example uses the Create method to instantiate a 1-tuple whose component is of type Int32.


// ww w .ja  v  a 2 s .com
using System;
public class MainClass{
  public static void Main(String[] argv){  
    var tuple1 = Tuple.Create(12);
    Console.WriteLine(tuple1.Item1);    
   
    tuple1 = new Tuple<int>(12);
    Console.WriteLine(tuple1.Item1);    

  }
}
    

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