When adding an Event Handler, use 'new()' or not?

c#, event-handling, new-operator

Solution

The second one is short hand for the first one, so both will create the event handler and add it to `Click`.

Here's a good explanation from the chapter on events in "C# in Depth."

Problem

Possible Duplicate: Attaching Eventhandler with New Handler vs Directly assigning it What is the difference between assigning a callback to, lets say a button's Click event by using `+= new(...)` versus just `+=`? Here are samples of each for clarity: ``` Button b = new Button(); b.Click += new System.EventHandler(button_Click); b.Click += button_Click; ``` Does the first one create a new instance of the method `button_Click` whereas the second always uses the one defined in this?

Original source

Related problems