Attaching Eventhandler with New Handler vs Directly assigning it

后端 未结 2 367
名媛妹妹
名媛妹妹 2020-12-03 15:31

What is the actual difference, advantages and disadvantages, of creating a new event handler, vs assigning it directly to the event?

_gMonitor.CollectionChan         


        
2条回答
  •  無奈伤痛
    2020-12-03 16:10

    The compiler has enough information available to make the new EventHandler effectively syntactic sugar.

    It knows that you are attaching an event handler to an event, as only += and -= are valid at this point, so you don't need tell it what to do.

提交回复
热议问题