How to test whether a value is boxed in C# / .NET?

后端 未结 9 1318
终归单人心
终归单人心 2020-12-13 00:32

I\'m looking for a way to write code that tests whether a value is boxed.

My preliminary investigations indicate that .NET goes out of its way to conceal the fact,

9条回答
  •  误落风尘
    2020-12-13 01:26

    If a type is a value type and its static type is 'dynamic' or 'object', or an interface, it is always boxed.

    If a type is a value type and its static type is the actual type, it is never boxed.

提交回复
热议问题