The use and difference of ref and out.

Source: Internet
Author: User

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.

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.