Value type: int a, directly allocates memory space in the stack (stack) to store values.
Reference type: preson a=new preson(), divided into two steps
- Preson a, declares, allocates space for storing references on the stack, of course, at this time, a points to null (because no value has been assigned, the default address of the reference type is null)
- a=new preson(), in the managed heap (in c#), allocate the memory space of type preson, and store the address of the memory space in the storage space of a on the stack,
Therefore, what is stored in a is not the preson instance, but the address reference of the instance.