What are c# Tuples?

In C#, a tuple represents a set of data in a single data structure. Tuples can:
1. Provide easy access and manipulation of a set of data.
2. Return multiple values from a method.
3. Pass multiple values to a method in a single parameter.

Example:

var myTuple = Tuple.Create("w3mentor", new DateTime(2009, 12, 8));
Console.WriteLine("{0} was created on {1}.", myTuple.Item1, myTuple.Item2);

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.