.. NET is divided into two types: Value Type and reference type, and a mechanism is designed in which all types are inherited from a root class: system. object, which is similar to all classes inherited from cobject in MFC.
A value-type instance is generally directly allocated to the stack and referenced by its address. When we want to allocate a reference type instance, we first create the Instance Storage Area in the heap, and then put a variable in the stack to store the address of the region. Our reference instance is actually the address value, not the bucket in the heap. At present, I have not understood the benefits of this design method.
As for packing, unpacking is to compare the basic type of value type with system. why do we need to design a conversion mechanism between object classes? I want to make a function that accepts object types, it not only accepts common class reference objects, but also accepts common value type objects. If we design all the basic types as reference types for this purpose, the execution effect will be more troublesome. After all, an int variable, instead of directly manipulating it, you need to use its address to perform operations around a bend, and it takes time and space. So we designed such a way.