If the left operand of a += or -= operator is classified as an event access,
then the expression is evaluated as
follows:
?The instance expression, if any, of the event access is evaluated.
?The right operand of the += or -= operator is evaluated, and, if
required, converted to the type of the left
operand through an implicit conversion (?3.1).
?An event accessor of the event is invoked, with argument list consisting
of the right operand, after
evaluation and, if necessary, conversion. If the operator was +=, the add
accessor is invoked; if the
operator was -=, the remove accessor is invoked.
An event assignment expression does not yield a value. Thus, an event
assignment expression is valid only
in the context of a statement-expression (?5.6).
then the expression is evaluated as
follows:
?The instance expression, if any, of the event access is evaluated.
?The right operand of the += or -= operator is evaluated, and, if
required, converted to the type of the left
operand through an implicit conversion (?3.1).
?An event accessor of the event is invoked, with argument list consisting
of the right operand, after
evaluation and, if necessary, conversion. If the operator was +=, the add
accessor is invoked; if the
operator was -=, the remove accessor is invoked.
An event assignment expression does not yield a value. Thus, an event
assignment expression is valid only
in the context of a statement-expression (?5.6).
事件赋值表达式解析
本文探讨了在编程中涉及事件赋值表达式的评估过程,包括+=和-=运算符的操作方式,以及如何通过调用相应的事件访问器来实现对事件的添加或移除操作。
1万+

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



