C# Tuple Create(T1, T2)
Description
Tuple Create (T1, T2)
creates a new
2-tuple, or pair.
Syntax
Tuple.Create<T1, T2>(T1, T2)
has the following syntax.
public static Tuple<T1, T2> Create<T1, T2>(
T1 item1,
T2 item2
)
Parameters
Tuple.Create<T1, T2>(T1, T2)
has the following parameters.
T1
- The type of the first component of the tuple.T2
- The type of the second component of the tuple.item1
- The value of the first component of the tuple.item2
- The value of the second component of the tuple.
Returns
Tuple.Create<T1, T2>(T1, T2)
method returns <
Example
Creates a new 2-tuple, or pair.
/*from w w w . j a v a 2 s. co 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);
//This code is equivalent to the following call
//to the Tuple<T1, T2> class constructor.
tuple2 = new Tuple<string, double>("New York", 32.68);
Console.WriteLine("{0}: {1}", tuple2.Item1, tuple2.Item2);
}
}
The code above generates the following result.