Use cases for boxing a value type in C#?

后端 未结 9 1149
既然无缘
既然无缘 2021-02-05 23:36

There are cases when an instance of a value type needs to be treated as an instance of a reference type. For situations like this, a value

9条回答
  •  一向
    一向 (楼主)
    2021-02-06 00:02

    One of the situations when this happens is for example if you have method that expect parameter of type object and you are passing in one of the primitive types, int for example. Or if you define parameter as 'ref' of type int.

提交回复
热议问题