C # basic notes (Seventh Day ),
1. constants, enumerations, structures, Arrays
2. In the Main () function, call the Test () function. We call the Main () function as the caller,
The Test () function is called the caller.
If the caller wants to obtain the value of the caller:
1) pass parameters.
2) use static fields to simulate global variables.
If the caller wants to obtain the value of the caller:
1) Return Value
3,
Both real parameters and form parameters open up space in the memory.
4. Methods must have a single function.
GetMax (int n1, int n2)
The most taboo in the method is the word prompting the user to enter.
5. out, ref, and params
1). out parameter.
If you return multiple values of the same type in a method, you can consider returning an array.
However, if multiple different types of values are returned, the returned array will not work. At this time,
We can consider using the out parameter.
The out parameter focuses on returning multiple different types of values in a method.
The out parameter must be assigned a value inside the method.
2) ref Parameters
A variable can be brought into a method for change. After the change is completed, the changed value is taken out of the method.
The ref parameter must be assigned a value outside the method, but not in the method.
Ref does not need to create a new variable to receive the return value.
3) variable params Parameters
The elements in the real parameter list that are consistent with the variable parameter array are processed as elements of the array.
The params variable parameter must be the last element in the parameter list.
Public static void Test (string name, params int [] score)
6. Method Overloading
Concept: Method overloading means that the method name is the same, but the parameters are different.
There are two different parameters:
1) if the number of parameters is the same, the parameter types cannot be the same.
2) If the parameter type is the same, the number of parameters cannot be the same.
* ** The method overload has nothing to do with the return value.
Which parameter is used?
You can place any parameters, such as console. writeline ();
For a layer-by-layer door, return returns only the previous layer.