【发布时间】:2016-09-22 11:30:01
【问题描述】:
+= 运算符有什么作用?很难在网上找到有关此运营商的信息,尽管这似乎表明它与代表有关。谁能解释一下?
反正下面是我遇到的c#语句:
this.LineSelected += new LineSelectionHandler(AdvancedReceiptViewModel_LineSelected);
【问题讨论】:
-
所以你知道它是一个运算符,所以为什么不从搜索C# operators 开始 - 第一个结果将指向你here:
The += operator is also used to specify a method that will be called in response to an event; such methods are called event handlers. The use of the += operator in this context is referred to as subscribing to an event. -
您可能不熟悉 VB.NET,但如果您熟悉的话,它相当于
AddHandler语句。
标签: c# event-handling