Is there an actual difference in the 2 different ways of attaching event handlers in C#?

后端 未结 2 1305
忘掉有多难
忘掉有多难 2020-12-07 01:58

In C# is there any real difference (other than syntax) under the hood between:

myButton.Click += new EventHandler(myMemberMethod);

and

2条回答
  •  广开言路
    2020-12-07 02:05

    They are exactly the same, its called syntax sugar.

    There are a lot of things that arent needed, to get a better idea of them while programming you should try something like Resharper. It will color the unnecessary code in Grey. Not to mention a whole myriad of incredible tools and refactorings.

提交回复
热议问题