当方法接受 ValueType 的 out/ref 参数时是否会发生装箱/拆箱?
最佳答案
对于 ref
关键字它已经在 MSDN 上提到了那:
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.
关于out
关键字:
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.
关于c# - 使用 out 和 ref 参数时的装箱和拆箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5103147/