14. C # Basic finishing (function)

Source: Internet
Author: User

Function

1, Concept: is a code block with input parameters, output parameters, return values.

2, the wording:

Modifier return value type function name (input parameter, input parameter)

{

Method segment

return value;

}

3. Comments:

(1) input parameter format: parameter type + variable name. Can not write

(2) return value type---Void is no return value, function body cannot write return

(3) "///" can bring up the comment of the function, which is convenient to view when referencing

(4) need to be under the same namespace as the main function

4. Example:

 Public int Jiafa (int A,int  b) {    return a +b;}

5. Call Method:

Enter a parameter call in the main function

Static void Main (string[] args) {    int a ,    b; 3 ;     5 ;     New Class (); // Initialize the class where the function resides first    C.jiafa (A, b); // call a function, or you can output }

14. C # Basic finishing (function)

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.