The difference between a value type and a reference type is that a variable of a value type directly holds the actual data, whereas a variable of a reference type holds the address of the data, that is, the object's reference.
A value type variable stores the value of a variable directly on the stack, and a variable of the reference type holds the address of the actual data on the stack, while the actual data is stored in the heap. Note that heap and stack are two different concepts, where storage is not the same in memory, heaps are typically used to store variable-length data, such as string types, while stacks are used to store fixed-length data, such as Integer type data int (each int variable occupies four bytes). Where the data is stored, it is known that when assigning a value variable to another value variable, two identical values are saved on the stack, and a reference variable is assigned to another reference variable, and two references to the same heap location are saved on the stack, that is, the address of the same heap is saved on the stack. In the case of data manipulation, for value types, because each variable has its own value, the operation of one variable does not affect other variables, and for a variable of reference type, manipulating the data of a variable is the operation of the data in the heap, if a variable of two reference types refers to the same object, The actual meaning is that they hold the same address of the heap on the stack, so manipulating one variable affects another variable that references the same object.
difference between a value class and a reference class