The role of C # ref

Source: Internet
Author: User

Usage of ref keyword in C #

When we pass a value type variable as a parameter, then it passes its value as a parameter i.e. making a copy of the data. Making any changes inside the method in which it has been passed as a parameter would not affect the variable accessed out Side the method. Because It is passed as a value and whatever the changes would be made inside the local method would be do on a copy of th At variable.

If we need to change the value of type variable from inside the method in which it had been passed as parameter, then you can Pass this value type variable as the reference, using the ' ref ' keyword. In this case, the reference of value type would be passed as a parameter rather than value of the variable

The role of C # ref

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.