14.4.3.1 Invocations on boxed instances

本文探讨了在特定情况下如何通过装箱实例调用值类型的成员函数,包括当成员函数覆盖了从object类型继承的方法、实现了接口成员函数或通过委托进行调用时的情景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值