开发者

Boxing and unboxing when using out and ref parameters

开发者 https://www.devze.com 2023-02-13 07:33 出处:网络
Does boxing/unboxing occur when a method accepts an out/re开发者_开发问答f parameter of a ValueType?For ref Keyword Its already mentioned on MSDN that :

Does boxing/unboxing occur when a method accepts an out/re开发者_开发问答f parameter of a ValueType?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号