C # Fundamentals 02

Source: Internet
Author: User

1, in the main () function, we call the test () function, we call the main () function called the caller,
The tube test () function is called the callee.
If the callee wants to get the caller's value:
1), passing parameters.
2), use static fields to simulate global variables.
If the caller wants to get the value of the callee:
1), return value

2.
Whether it is an argument or a formal parameter, it opens up space in memory.

3, the method must be a single function.
Getmax (int n1,int n2)
The most taboo in the method is the word that prompts the user to enter.

4, out, ref, params
1), out parameters.
If you are returning multiple values of the same type in a method, you might consider returning an array.
However, if you return a number of different types of values, the return array will not be, then this time,
We can consider using out parameters.
The out parameter focuses on the ability to return several different types of values in a method.

2), ref parameter
The ability to take a variable into a method to change, after the change is completed, then the change in the value of the method.
The ref parameter requires that a value be assigned outside the method, and the method may not be assigned a value.

3), params variable parameter
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.

5. Overloading of methods
Concept: Overloading of methods means that the name of the method is the same, but the parameters are different.
Different parameters, divided into two kinds of situations
1), if the number of arguments is the same, then the type of the parameter cannot be the same.
2), if the parameters of the same type, then the number of parameters can not be the same.
The overloads of the method are not related to the return value.

6. Recursion of the method
Method itself to invoke itself.
Find all the files in a folder.

C # Foundation

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.