C#: Difference between ' += anEvent' and ' += new EventHandler(anEvent)'



Answers

[object].[event] += anEvent;

is just syntactic sugar for -

[object].[event] += new EventHandler(anEvent);
Question

Take the below code:

private void anEvent(object sender, EventArgs e) {
    //some code
}

What is the difference between the following ?

[object].[event] += anEvent;

//and

[object].[event] += new EventHandler(anEvent);

[UPDATE]

Apparently, there is no difference between the two...the former is just syntactic sugar of the latter.




Links