Creating tuples C# with Example
Tuples are created using generic types Tuple-Tuple. Each of the types represents a tuple containing 1 to 8 elements. Elements can be of different types. // tuple with 4 elements var tuple = new Tuple("foo", 123, true, new MyClass()); Tuples can also be created using static Tuple.Create methods. In this case, the types of the elements are inferred by the C# Compiler. // tuple with 4 elements var tuple = Tuple.Create("foo", 123, true, new MyClass()); Version ≥ 7.0 Since C# 7.0, Tuples can be easily created using ValueTuple. var tuple = ("foo", 123, true, new MyClass()); Elements can be named for easier decomposition. (int number, bool flag, MyClass instance) tuple = (123, true, new MyClass());