码迷,mamicode.com
首页 > Windows程序 > 详细

c# ref 的作用

时间:2016-12-07 20:18:49      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:can   type   nbsp   using   c#   his   out   ever   because   

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 will not affect the variable accessed outside the method. Because it is passed as a value and whatever the changes will be made inside the local method will be done on a copy of that variable.

If we need to change the value type variable from inside the method in which it has 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 will be passed as a parameter rather than value of the variable

c# ref 的作用

标签:can   type   nbsp   using   c#   his   out   ever   because   

原文地址:http://www.cnblogs.com/huchaoheng/p/6142416.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!