Difference between the value type and the reference type
1. A Value Type object has two representation forms: unboxed and boxed. On the contrary, the reference type is always in the boxed form. 2. The value type is derived from System. ValueType. This type provides the same method as System. Object. However, System. ValueType overrides the Equals method and returns true if the field values of the two objects are completely matched. In addition, System. ValueType overrides the GetHashCode method. When a hash code is generated, the algorithm used by this rewrite method takes the value in the instance field of the object into consideration. Because this default implementation has performance problems, you should override the Equals and GetHashCode methods when defining your own value types and provide their display implementation 3, because the value type cannot be used as the base type to define a new value type or a new reference type, no new virtual method should be introduced in the value type, all methods cannot be abstract. All methods are implicitly sealed (not rewritable). 4. variables of the reference type include the address of the object in the heap. When a variable of the reference type is created, the initialization is null, and the table name does not point to a valid object currently. If the view uses a null reference type variable, an NUllReferenceException is thrown. On the contrary, variables of the Value Type always contain values of the basic type, and all members of the value type are initialized to 0. the value type variable is not a pointer, and the Access value type cannot throw NullReferenceExcption exception 5. Assign the value type variable to another value type variable and assign the value by field. Assign a value to a variable of the reference type to another variable of the reference type and only copy the memory address 6. Two or more references can reference the same object in the heap, therefore, operations performed on one variable may affect another referenced object. On the contrary, value type variables are self-contained, and the operations performed on value type variables cannot affect another value type variable 7, because unboxed value types are not allocated on the stack, once the methods for defining an example of this type are not active, the storage allocated to them will be released instead of waiting for garbage collection.