IL 二校汇总

When we declare a value type variable, we create a data structure. When we box this variable, an object (a class instance) is created whose data part is an exact bit copy of the data structure. Then we can deal with this instance the same way we would deal with an ordinary object—for example, we could use it in a call to a method, which takes an object reference as a
parameter. It is important to understand that the “original” instance of a value type does not go anywhere after it has been boxed. Its copy does. And what happens to this copy is not reflected back to the original instance of the value type. This effect is known as a problem of mutability of the boxed value types. It is up to the author of the code to propagate possible
changes inflicted upon the boxed instance of the value type back to the original instance.

当声明一个值类型变量时,就创建了一个数据结构。当对这个变量进行装箱时,就会创建一个对象(一个类的引用),它的数据部分就是这个数据结构的准确的逐位复制(bit copy)。然后,可以像处理普通对象那样处理该实例——例如,可以使用实例的调用方法,它会接收一个对象引用作为参数。装箱操作后值类型的原始实例不能任意移动,理解这点是非常重要的。它的副本是可以移动的。它的副本无论发生了什么改变都不会反过来影响值类型的原始例。这种效果称为已装箱类型的不稳定性。代码的作者有必要传播可能的改动会影响到值类型的已装箱实例。由值类型的装箱实例造成的改变不会反过来影响值类型的原始

原文地址:https://www.cnblogs.com/Jax/p/1361929.html