C # params Application

Source: Internet
Author: User

Params is a keyword in C # development language,

Params is mainly used when passing parameters to the function, that is, when the parameters of the function are not fixed.

After the params keyword in the method declaration, no other parameters are allowed, and only one params keyword is allowed in the method declaration.

You need to know the following about parameter Arrays.

(1) If a parameter array is included in the parameter table, the parameter array must be at the end of the parameter list;

(2) The parameter array must be a one-dimensional array;

(3) You are not allowed to combine the params Modifier with the ref and out modifiers;

(4) The real parameter corresponding to the parameter array can be an array name of the same type, or multiple variables of the same type as the elements of the array;

(5) If the real parameter is an array, it is passed by reference. If the real parameter is a variable or expression, it is passed by value.

(6) usage: variable method parameters, also called array parameters, are suitable for passing a large number of array set parameters when the number of method parameters is unknown, you can use the params keyword to specify multiple method parameters in the form: method modifier return type method name (params type [] variable name)

For SQL statements with parameters, the number of fields in different tables is also different. When you update and modify the statements, you can use params.

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.