There are two options for subscribing to events:
this.button1.click += new System.EventHandler(this.button1_Click)
开发者_如何学编程
this.button1.click += this.button1_click
What are the advantages and disadvantages of both techniques?
The second one is easier to read ;-) - they both work in the same way.
The second option is preferred by many - including ReSharper - because it is easier to read and less code. The generated IL code however is the same, so it is purely a question of preference.
Second option is only syntactic sugar for the first one.
You can check generated IL-code and you'll see that compiler generates exactly the same IL-code for both cases.
精彩评论