Function enumeration and Recursion

Source: Internet
Author: User

1. Functions

A large program is generally divided into several program blocks, each of which is used to implement a specific function. Subprograms are used in all advanced languages to implement the functions of modules. In C #, subprograms are composed of a main function and several functions. Other functions can be called by the main function. The same function can be called multiple times by one or more functions.

In program design, some common functional modules are often written into functions and put in the function library for public selection. Be good at using functions to reduce the workload of repeatedly writing program segments.

Void is a parameter with no return value
Private can only be used in the current class, public, and can be used throughout the namespace

In order not to forget the function when using this function in the future, you need to add some comments so that you can place the cursor over it to display the comments that have been written, when using this function, input // on the function, that is, three slashes.

One function is to pass the value, and the other is to pass the address:

Passing the value is to pass the value of the real parameter to the called function. The value of the real parameter has not changed. The default values include int type, floating point type, bool type, and char character type, struct.

The address transfer operation is to upload the address to the called function. The value of the real parameter also changes. The address is an array and a string.

The data classification is involved in the above description, which includes the value type and reference type. The value type is the type of the passed value. The reference type includes the string type, array and object, and the string type is special, the main reason is that the string is actually a char [] array. It is not directly modified during modification, but a new bucket is opened, that is, a new string is created, so it is equivalent to passing a value when calling and assigning values, but it is of reference type!

2. Enum Enumeration

Exercise:

3. Recursion

Recursion is characterized by self-calling itself; return is to return the value to the upper level;

Function enumeration and Recursion

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.