Tuples were introduced in .NET 4.0. While arrays hold objects of the same type, tuples can hold objects of different types. The eight different generic Tuple classes are available for the purposes of having tuples with diferent number of types. Once a tuple was created the type of its fields cannot be changed. In a way, using a tuple is similar to using a value type.

The .NET 4.0 includes eight different generic Tuple classes and one static Tuple class that works as a factory for getting tuples. Calling the Tuple.Create() static method we can get a new tuple.

The following video clips explain various aspects related to using tuples in our code. I have just completed to update my C# Fundamentals course at www.abelski.com. You can get the source code as well as more training material about tuples in C# at www.abelski.com.

Leave a Reply

Your email address will not be published. Required fields are marked *