c# - What is Difference in assign an event...the correct method? -


Can you tell me what is the difference between these methods of adding an event handler?

  // Method 1 this.button4.Click + = New Routing EventHandler (Button 4_Click); // Method2 this.button4.Click + = button4_Click; ... Zero Button 4_Click (Object Sender, RoutedEventArgs E) {}  

As Anton says, there is no difference.

Just a bit of background, it is not specific for the events. In C # 2.0, this feature has only one use, which is an unbalanced conversion of method groups for delegates. So you can use it like this:

  EventHandler handler = button 4_click; Another variation for delegates in C # 2.0 is that they are different now - this means that (for example) you declare as a mousevent handler with Event Hender signature. You can use the method:  
  MouseEvent handler = button 4_click;  

Then there are unnamed methods, but this is totally different ballgame :)


Comments