The ref keyword causes an argument to be passed by reference, not by value. The effect of passing by reference is that any change to the parameter in the called method is reflected in the calling method. For example, if the caller passes a local variable expression or an array element access expression, and the called method replaces the object to which the ref parameter refers, then the caller’s local variable or the array element now refer to the new object.
Note: Do not confuse the concept of passing by reference with the concept of reference types. The two concepts are not the same. A method parameter can be modified byref regardless of whether it is a value type or a reference type. There is no boxing of a value type when it is passed by reference.
To use a ref parameter, both the method definition and the calling method must explicitly use theref keyword. An argument that is passed to a ref parameter must be initialized before it is passed.
原文地址:http://blog.csdn.net/troubleshooter/article/details/40541239