the memory is divided into two main spaces: stack space and heap space. They are all used to store data. Different types of data are stored in different places. One, value types and reference types are divided by: they are stored in memory in different structures. value type: all numeric types, char, bool, enum, struct Reference type:string array class third, local variables and member variables:3.1. Local variables:The same point: Whether a local variable is a value type or a reference type, the local variable is always opened in the stack space.difference: The real value of a value type variable is stored directly in the variable in the stack space.A variable of a reference type that is stored in the heap space and stored in a variable in the stack space is the address of the object in the heap space.3.2. member variables:the member variable is in addition to the object. Whether this member variable is a value type or a reference type, it is opened in the heap space along with the object. This member variable stores values in the same principle as local variables. iv. Effects of reciprocal assignment between variablesno matter what type of variable is assigned to each other. Copy the value from the source variable and assign the copy to the target variable. The difference is:value type: Because the value type of the variable is stored in the real value, so the copy passed is also the true value. When the assignment is complete, modifications to one variable do not affect the value of the other 1 variables. reference type: Because the object's address is stored in a variable of the reference type, the copy is also passed the address. When the assignment is complete, two variables point to the same object. Modifications to 1 variables have an effect on the other variables.
Value types and reference types