Stan Lippman on Supporting Direct Handles to Boxed Value Types
Yes, the need to box occurs only when the source of the assignment to an Object^ is a value type. A Value type, recall, maintains its state within each associated object [what in C++ is created when we write T t]. A Reference type is a duple in which the named instance is a handle holding either null or the address of an unnamed object allocated on the managed heap. When we initialize the Object^ second parameter of Console::WriteLine with a Value type, there is a hiccup in the unified type system because there is no way to represent the Value type directly within the handle of a Reference type. The solution is to create a shadowed Reference to the Value type on the managed heap and pass in the address of that object.