In C#, what is boxing?
Correct answer B. Converting a value type to object or an interface type, which copies it into a heap object
Boxing happens when a value type such as int is converted to object or to an interface it implements. The runtime allocates an object on the managed heap and copies the value into it. The reverse, unboxing, is an explicit cast back to the exact value type. Because each box costs an allocation, generic collections like List are preferred to ArrayList.
Answer checked How we write and check questions
Discussion