Note: For beginners, self-study Yu Shunji podcasts.
1.out parameters.
Concept: If you return multiple values of the same type in a method, consider returning an array. However, when returning multiple values of different types, it is obvious that the returned array does not solve the problem, and an out parameter is introduced. The out parameter focuses on the ability to return several different types of values in a method.
code example:
User login:
Main: Test (Numbers, out-max1, out-min1, out-sum1, out-avg1, out-B, out-S, out D);
method:public static void Test (int[] nums, out int max, out int min, out int sum, out int avg, out bool B, out string s, out double D)
{...}
2.ref parameters.
Concept: The ability to take a variable into a method to change, after the change is completed and then the changed value out of the method, the ref parameter requires that the method must be assigned to it, and the method can not be assigned to a value.
code example:
Main: Test (ref n1, ref N2);
method:public static void Test (ref int n1, ref int n2)
{...}
3.params variable parameters.
Concept: The elements of the argument list that are consistent with the variable parameter array type are treated as elements of the array. The params variable parameter must be the last element in the formal parameter list.
code example:
Main: Test ("Zhang San", 158412,100,100,100);
method:public static void Test (string name, int ID, params int[] score)
{...}
Three important parameters in C # methods: Out, ref, params