A tuple type is like a pocket, where you can put everything you need in front of your head. You can put your keys, your driver's license, your pad and your pen in your pocket, and your pocket is a collection box for all kinds of things. A new feature introduced by C # 4.0 The tuple type is similar to a pocket, and it can hold different types of objects. CodeProject on the article "C # 4-tuples" Comprehensive introduction of the tuple.
Before C # 4.0, our function had multiple return values, usually using Ref,out. to C # 4.0 you should use tuple tuple instead of the output parameter, at any time avoid using Ref/out to pass parameters, especially reference types (references that prohibit references, try to improve your design.
Arrays combine objects of the same type, and tuples combine different types of objects. Tuples originate from functional programming languages such as F #, which frequently use tuples in these languages.. NET 4 defines 8 generic tuple classes and a static tuple class, which are used as factories for tuples. The different generic tuple classes here support a different number of elements. For example,tuple<t1> contains an element,tuple<t1,t2> contains two elements, and so on.
tuple<boolnew tuple<boolstring> (false"Robin ");
Related reading: [You must know the. NET] 32nd time, in depth. NET 4.0, tuple one or two
C # tuple tuple