Out parameter ref parameter params variable parameter, refparams

Source: Internet
Author: User

Out parameter ref parameter params variable parameter, refparams

1. When we call other functions in the main function, we assume that the main function is the caller,
Other functions are called.
If the caller wants to get the value of the caller: passing the Parameter
Use static fields to simulate the write range of global variables outside the method class public static _ name = 10;

2. If the caller wants to obtain the value of the caller
1. Return Value
No matter whether the form parameter or the actual parameter is open up space
Methods must have a single function.
Evaluate the leap year in the method, and write another method to calculate the maximum value. Do not write it together.
Tips for user input

3. OUT parameter (multiple values of different types are returned)
If you return multiple values of the same type in the method, consider arrays.
However, if you want to return multiple different types of values, you cannot return an array.
The out parameter is more important than returning multiple different types of values in a method.
The out parameter must be assigned a value inside the method.

4. ref parameter: (bringing a variable into the method)
The ability to bring a variable into a method for change. After the change is completed, the changed value is introduced into the method.
Requirement: A value must be assigned to a method, but not to a method.
Prompt username and password respectively
Write method to determine whether user input is correct
Returns a login result to the user, and returns a login information to the user separately.
If the login user name is incorrect, besides the login result, the user name error is returned.

5. Variable params parameters:
The elements in the real parameter list that are consistent with the variable parameter array type are treated as array elements.
Elements that can be passed in and in the array type
Params must be the last parameter (unique) in the parameter list)
Returns the maximum value and integer value of an array of any length.

6. Method Overloading
Concept: The method is overloaded with the same method name, but the parameters are different.
1): if the number of parameters is the same, the types cannot be the same
2): If the parameter type is the same, the number cannot be the same
There is no relationship between the method overload and the return value of the method.
7. recursion of a method: The method calls itself, but there must also be a condition for it to end recursion.
When certain conditions are met, recursion must be stopped.
Find all files in a folder
Recursive Execution Process: It is equivalent to 10 rows, and 10 rows are generated after recursion.
1 2 3 4 5 6 7 8 8 7 6 5 4 3 2 1 out

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.