C # methods, method declarations, method calls, and method overloading!

Source: Internet
Author: User

1. Definition: The method is an executable code block with a name.

2. method declaration: the syntax for declaring a method includes the following five parts:

1. access permission modifier. This is an optional parameter. The default value is private access, that is, only internal access from the declared class is allowed.

2. Return type. If no value is returned, the return type is specified as void.

3. method name.

4. Parameters. Optional.

5. The method body consists of a pair of braces, which contains executable code.

3. The parameters of the method are declared in the parameter list of the method, and the parameters of the method are in the parameter list of the method call.

4. Call and return values of methods. To return values, the method must declare a return type before the method name. If the method does not return values, it must be declared as void.

5. Method overload: A class can have more than one method with the same name, which is called method overload ).

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.