Tuples enhancement

Tuples were introduced into C# language in Version 4 and are used in the simplified form to provide structure with two or more data elements, allowing you to create methods that can return two or more data elements. Before C# 7, referencing the elements of a tuple was done by using Item1, Item2, ...ItemN, where N is the number of elements in the tuple structure. Starting from C# 7, tuples now support semantic naming of the contained fields with the introduction of cleaner and more efficient ways of creating and using tuples.

You can now create tuples by directly assigning each member to a value. This assignment creates a tuple containing elements Item1, Item2:

var names = ("John", "Doe");

You can also create tuples that ...

Get C# and .NET Core Test Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.