Boxing and unboxing: when does it come up?

前端 未结 7 915
灰色年华
灰色年华 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:39

    Boxing and unboxing is really moving from value type to reference type. So, think of it as moving from the stack to the heap and back again.

    There certainly are cases where this is relevant. The inclusion of generics in the 2.0 framework cut a lot of common boxing cases out of practice.

提交回复
热议问题