Does passing a value type in an “out” parameter cause the variable to be boxed?

后端 未结 4 1765
长发绾君心
长发绾君心 2020-12-11 01:27

I\'m aware that boxing and unboxing are relatively expensive in terms of performance. What I\'m wondering is:

Does passing a value type to a method\'s out

4条回答
  •  眼角桃花
    2020-12-11 02:04

    No, there is no Boxing (required/involved).

    When you do Box a variable, changes to the boxed instance do not affect the original. But that is exactly what out is supposed to do.

    The compiler 'somehow' constructs a reference to the original variable.

提交回复
热议问题