04-05 Understanding Value Types and Reference Types
Simply put, the role of System.ValueType is to ensure that the derived type (e.g., any structure) is allocated on the stack, rather than the garbage-collected heap.
简单的说,System.ValueType 的角色是确保继承此类的基类是在堆栈中分配空间而不是垃圾处理的堆中。
Functionally, the only purpose of System.ValueType is to override the virtual methods defined by System.Object to use value-based, versus reference-based, semantics.
从功能上来讲,System.ValueType的目的就是重写ystem.Object定义的虚方法来使用基于值得语法。
Because Point is a value type, you have two copies of the MyPoint type on the stack, each of which can be independently manipulated.
因为Point是值类型,你可以有2份MyPoint 在堆栈中,每一份可以独立操作。
In stark contrast to value types, when you apply the assignment operator to reference types (meaning all class instances), you are redirecting what the reference variable points to in memory.
与值类型截然相反,当你应用赋值操作符到引用类型,你重新纸箱引用变量指向的内存变量。

浙公网安备 33010602011771号