C # group meta Tuple
Group Meta is a new feature introduced by C #4.0. It must be Based on. NET Framework 4.0 or later. Group elements use generics to simplify the definition of a class. Group elements are mostly used
Method return value. If a function returns multiple types, it does not use output parameters such as out \ ref. You can directly define a Tuple type.
1.0 simple use
// A member Tuple
Test = new Tuple
(1); Console. WriteLine (test. Item1); // two members, Tuple
Test1 = new Tuple
(2, 2.3); Console. WriteLine (test1.Item1 + test1.Item2 );
2.0 nested use
TupleA maximum of 8 members are supported.If there are more than eight, nesting is required.
Note that 8th members are special. 8th members must be nested into the Tuple type.
// Non-8 elements, Tuple
> Test2 = new Tuple
> (3, new Tuple
("Nesting"); Console. WriteLine (test2.Item1); Console. WriteLine (test2.Item2); // eight elements Tuple
> Test3 = new Tuple
> (1, 2, 3.0f, 4, 5, 6, 'h', new Tuple
(8); Console. WriteLine (test3.Item1 + test3.Rest. Item1 );