C# Tuple

C# Tuple is available in .NET 4.5 version or higher. It is similiar to dictionary, however, it may contains many fields (rather than 2 fields in dictionary), and all elements can be of different type.

using System;
Tuple<string,double,int> tpl = new Tuple<string,double,int>();

The field type can be of array or any type.
Tuple<int[],string,bool,string> tpl = new Tuple<int[],string,bool,string>();
tpl.Item1 = new int[] {3,7,9,12};
tpl.Item2 = "csharp";
tpl.Item3 = true;
tpl.Item4 = "tutorial";

endmemo.com © 2017  Terms of Use | Home