Posts

Showing posts with the label #C# #Tuples

C# Tuples

C# tuple is a data structure that is used to store sequence of elements. Tuple with n elements are known as n-tuple. We can use Tuple for the following reasons. To represent a single set of data To provide easy access and manipulation of data To return multiple values from a method without using  out  parameter To pass multiple values to a method through a single parameter In C#, tuple is a class that contains static methods. These methods are used to create tuple objects. Following is the syntax of Tuple class. C# Tuple Class Syntax public   static   class  Tuple   C# Tuple Methods The following table contains methods of Tuple class. Method name Description Create<T1>(T1) It is used to create a new 1-tuple, or singleton. Create<T1,T2>(T1,T2) It is used to create a new 2-tuple, or pair. Create<T1,T2,T3>(T1,T2,T3) It is used to create a new 3-tuple, or triple. Create (T1,T2,T3,T4) It is used to create a new 4-tuple, or quadruple. Creat...