Is there a benefit to explicit use of “new EventHandler” declaration?

前端 未结 4 1091
隐瞒了意图╮
隐瞒了意图╮ 2021-01-12 04:28

In assigning event handlers to something like a context MenuItem, for instance, there are two acceptable syntaxes:

MenuItem item = new MenuItem(         


        
4条回答
  •  渐次进展
    2021-01-12 04:59

    It's syntax for older version of C# compiler (<=1.1). Not needed anymore. Current compilers are sophisticated enough to get it right.

    There's one (little) benefit, sometimes. If you assign event handlers by "+=", the Intellisense autocomplete feature may make writing code a bit faster.

提交回复
热议问题