2

While i am using resharper he always say

enter image description here

what is the difference?

any details will be nice

Thanks for you all.

HB MAAM
  • 3,913
  • 4
  • 29
  • 39
  • 2
    possible duplicate of [+= new EventHandler(Method) vs += Method](http://stackoverflow.com/questions/2749868/new-eventhandlermethod-vs-method) or [Should I instantiate a new delegate or not?](http://stackoverflow.com/questions/4676399/should-i-instantiate-a-new-delegate-or-not) or [Difference between wiring events using “new EventHandler” and not using new EventHandler"?](http://stackoverflow.com/questions/5468868/difference-between-wiring-events-using-new-eventhandlert-and-not-using-new-e) – SwDevMan81 Mar 29 '12 at 20:23
  • 2
    Or [C#: Difference between ' += anEvent' and ' += new EventHandler(anEvent)'](http://stackoverflow.com/questions/550703/c-difference-between-anevent-and-new-eventhandleranevent) – SwDevMan81 Mar 29 '12 at 20:28
  • 1
    bc resharper is a bloated hog eating your cpu like dorritos // only slightly sarcastic – payo Mar 29 '12 at 22:30

2 Answers2

7

The shorter syntax has been introduced in C# 2.0 and it's just a syntactic sugar of the longer form.

No matter what you write, the result is always the same. However, the shorter is more readable.

Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188
Wiktor Zychla
  • 47,367
  • 6
  • 74
  • 106
4

There really is no difference. The "new MouseEventHandler" part is implied.

Mike Parkhill
  • 5,511
  • 1
  • 28
  • 38