System.Tuple

Added in .NET 4.0
A tuple is a data structure that has a specific number and sequence of elements
The framework directly supports tuples with one to seven elements
You can create tuples of either or more elements by nesting tuple objects in the Rest property
A tuple is a sequence of values that are grouped as one logical unit.
It is similar to data structure or user defined type in VBA.
A tuple that contains n components is called an n-tuple.
Tuples can contain data that includes seven different data types.


class Program 
{
    static void Main()
    {
        System.Tuple<int, string, bool> tuple = new System.Tuple<int, string, bool>(1, "cat", true);
            
        if (tuple.Item1 == 1)
        {
            System.Console.WriteLine(tuple.Item1);
        }
        if (tuple.Item2 == "dog")
        {
            System.Console.WriteLine(tuple.Item2);
        }
        if (tuple.Item3)
        {
            System.Console.WriteLine(tuple.Item3);
        }
    }
}


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext