return tuple in c# code example
Example 1: c# return two variables of different types
(string, string, int) LookupName(long id)
{
...
return (first, middle, myNum);
}
Example 2: c# tuple access
var numbers = Tuple.Create(1, 2, Tuple.Create(3, 4, 5, 6, 7, 8), 9, 10, 11, 12, 13 );
numbers.Item1;
numbers.Item2;
numbers.Item3;
numbers.Item3.Item1;
numbers.Item4;
numbers.Rest.Item1;
Example 3: c# tuple
var tupleList = new List<Tuple<int, string, string, string>>();
tupleList.Add(Tuple.Create(1, "Sefat Anam", "Dhaka Bangladesh", "0.1245345"));
Example 4: c# method returns multiple values
public Tuple<int, int> GetMultipleValue()
{
return Tuple.Create(1,2);
}