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

前端 未结 4 1283
心在旅途
心在旅途 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:32

    The C# compiler translates += operator to the call of the static method Delegate.Combine.

    There are several cases when the compiler does such things, f.e. the + operator of the System.String is compiled to the String.Concat call. Therefore there isn't op_Add method in System.String.

提交回复
热议问题