Because unboxed value types don’t have a sync block index, you can’t have
multiple threads syn-chronize their access to the instance by using the methods
of the System.Threading.Monitor type
(or by using C#’s lock
statement).
Even though unboxed value types don’t have a type object pointer,
you can still call virtual meth -ods (such as Equals , GetHashCode , or
ToString ) inherited or overridden by the type. If your value
type overrides
one of these virtual methods, then the CLR can invoke the method nonvirtually be
-cause value types are implicitly sealed and cannot have any types derived from
them. In addition, the
value type instance being used to invoke the virtual
method is not boxed. However, if your override
of the virtual method calls
into the base type‘s implementation of the method, then the value type
instance does get boxed when calling the base type‘s implementation so that
a reference to a heap
object gets passed to the this pointer into the base
method.
However, calling a nonvirtual inherited method (such as GetType or
MemberwiseClone) always
requires the value type to be boxed because these
methods are defined by System.Object , so the
methods expect the this
argument to be a pointer that refers to an object on the heap.
In addition,
casting an unboxed instance of a value type to one of the type’s interfaces
requires the
instance to be boxed, because interface variables must always
contain a reference to an object on the
heap.
原文:http://www.cnblogs.com/mdfxp/p/3660682.html