There has been a lot of explanation about the usage and the difference between ref and out, and it's just an explanation that's easier to understand than to write about me.
Both ref and out can be used to return data in a function, similar to pointers in C + +.
Parameters |
Ref |
Out |
Must be initialized |
Is |
Whether |
Mechanism |
The address of the passed parameter, such as declaring theint i=0; Iis an address stored in the memory heap0x000001so that's the address.0x000001 |
No initialization is required, that is, there is no storage space for the defined variables. is defined in the function body, so it is just the return value. (if previously defined, it is emptied in the body of the function before assigning a value) |
General purpose |
The call method modifies a reference to a parameter passed in (for example, the value of a string). |
suitable for use in NeedRetrun where multiple return values are |
Image memory |
There are in and out |
Just can't get in. |
The use and difference of ref and out.