A function member implemented in a value-type can be invoked through a boxed
instance of that value-type
in the following situations:
?When the function member is an override of a method inherited from type
object and is invoked
through an instance expression of type object.
?When the function member is an implementation of an interface function
member and is invoked
through an instance expression of an interface-type.
?When the function member is invoked through a delegate.
In these situations, the boxed instance is considered to contain a variable
of the value-type, and this variable
becomes the variable referenced by this within the function member
invocation. [Note: In particular, this
means that when a function member is invoked on a boxed instance, it is
possible for the function member to
modify the value contained in the boxed instance. end note]
instance of that value-type
in the following situations:
?When the function member is an override of a method inherited from type
object and is invoked
through an instance expression of type object.
?When the function member is an implementation of an interface function
member and is invoked
through an instance expression of an interface-type.
?When the function member is invoked through a delegate.
In these situations, the boxed instance is considered to contain a variable
of the value-type, and this variable
becomes the variable referenced by this within the function member
invocation. [Note: In particular, this
means that when a function member is invoked on a boxed instance, it is
possible for the function member to
modify the value contained in the boxed instance. end note]
本文探讨了在特定情况下如何通过装箱实例调用值类型的成员函数,包括当成员函数覆盖了从object类型继承的方法、实现了接口成员函数或通过委托进行调用时的情景。

被折叠的 条评论
为什么被折叠?



