Unlimited parameter writing and parameter writing

Source: Internet
Author: User

Unlimited parameter writing and parameter writing

Declared list <class> paras. To Add each para, you need to write paras. Add (para). If you can write paras. Add (para1, para2,...), that's all.

After checking the information, the infinite parameter keyword of C # Is params. List <Class> can be replaced by generics, and then the extension method of List <T> can be written.

1 public static void AddParas <T> (this List <T> paras, params T [] para) {2 for (int I = 0; I <para. length; I ++) 3 {4 paras. add (para [I]); 5} 6}

OK.

Copyright Disclaimer: This article will be published at http://www.cnblogs.com/keithmoring/, and you will be welcomed to enjoy the transfer. Please respect the work of the author. Keep this note and the author's blog link when reprinting. Thank you!

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.