C# Tuple Create(T1)

Description

Tuple Create (T1) creates a new 1-tuple, or singleton.

Syntax

Tuple.Create<T1>(T1) has the following syntax.


public static Tuple<T1> Create<T1>(
  T1 item1
)

Parameters

Tuple.Create<T1>(T1) has the following parameters.

  • T1 - The type of the only component of the tuple.
  • item1 - The value of the only component of the tuple.

Returns

Tuple.Create<T1>(T1) method returns <

Example

Creates a new 1-tuple, or singleton.


// w ww  .  j a  va  2s  . c o m
using System;
public class MainClass{
  public static void Main(String[] argv){  
    var tuple1 = Tuple.Create(12);
    Console.WriteLine(tuple1.Item1);     // Displays 12
    //This code is equivalent to the following call to the Tuple<T1> class constructor.
    tuple1 = new Tuple<int>(12);
    Console.WriteLine(tuple1.Item1);     // Displays 12

  }
}
    

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