Why don't I see the += operator overloaded on System.Delegate?

前端 未结 4 1271
心在旅途
心在旅途 2021-01-12 19:03

I see the equality comparison operators == and != overloaded on System.Delegate and MulticastDelegate but not the +

4条回答
  •  不思量自难忘°
    2021-01-12 19:33

    When you declare a delegate as an event, it is actually an event wrapper around the delegate. See https://stackoverflow.com/a/4893006/397807 for the details. In short, you can only add a handler with += and remove with -= and compiler will help translate it to proper function call.

提交回复
热议问题