C # tuple tuple

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.