Boxing and unboxing: when does it come up?

前端 未结 7 866
灰色年华
灰色年华 2020-12-01 11:22

So I understand what boxing and unboxing is. When\'s it come up in real-world code, or in what examples is it an issue? I can\'t imagine doing something like this example:

相关标签:
7条回答
  • 2020-12-01 11:50

    It happens all the time when people do not know what the implications are, simply don't care or sometimes one cannot help but accept boxing as the lesser evel.

    Strongly typed datarows will box/unbox pretty much all the time when you access a value-type property. Also, using a value type as an interface reference will box it as well. Or getting a delegate from an instance method of a value type. (The delegate's target is of type Object)

    0 讨论(0)
提交回复
热议问题