Does boxing/unboxing occur when a method accepts an out/ref parameter of a ValueType?
Asked
Active
Viewed 4,968 times
23
-
Possible duplicate of [C# - Does using a value type with an `out` parameter cause the variable to be boxed?](http://stackoverflow.com/questions/4807086/c-does-using-a-value-type-with-an-out-parameter-cause-the-variable-to-be-box) – Fredrik Mörk Feb 24 '11 at 10:18
1 Answers
33
For ref
Keyword Its already mentioned on MSDN that :
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 by ref 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.
As for out
keyword:
The out keyword causes arguments to be passed by reference. This is like the ref keyword, except that ref requires that the variable be initialized before it is passed.

Shekhar_Pro
- 18,056
- 9
- 55
- 79