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