Monday 16 June 2014

What is boxing and unboxing?

Purpose:
  • Understanding the difference between the stack and the heap and how your coding actions influence what happens at such a fundamental level illustrates a deep understanding of the framework and is a really good sign.

Potential Answer:
Boxing is name given to the process whereby a value type (that is primitive types like INT32 and LONG that reside on the stack) is converted into a reference type (like classes and arrays that reside on the heap). 

Unboxing represents the opposite behavior for when a class is designed for use with objects: for example, using an List to store integers. When you store an integer in the List it gets boxed. When you retrieve an integer, it must be unboxed once again to be used.

No comments:

Post a Comment