c# - What constitutes 'redundant delegate creation'? -


I was registering for an event in my class, and as always I was lazy and just self-contained Is used by the Visual Studio 2008 Pro which automatically builds a representative build and is an associated method.

  Public abstract class FooBase {secure event eventhandler & lt; MyValueChangedArgs & gt; MyValueChanged; Protected FooBase () {MyValueChanged + = New Event Handler & lt; MyValueChangedArgs & gt; (HandleMyValueChanged); } Private Voed Handle Mwleyle Chenzed (Object Sender, MyLife ChengErgus E) {// Some Handling Logic}} Usually I do not think twice when Visual Studio creates event handlers for me, but then recommend me with a refactor! Results of the recommendation for Pro "Remove unnecessary representative representatives":  
  Public abstract class FooBase {secure event event handler & lt; MyValueChangedArgs & gt; MyValueChanged; Protected FooBase () {MyValueChanged + = HandleMyValueChanged; } Private Wide Handle Moved Switch (Object Sender, Mewly ChangeZRGS) {// Some Handling Logic}}  

What is unnecessary in the representative situation and where the representative representative is appropriate?

Thank you.

I think the refactor! Tells you that the line

  MyValueChanged + = new event handler & lt; MyValueChangedArgs & gt; (HandleMyValueChanged);  

can be minimized and the compiler will build an event handler and guess the TEventArgs type logic ...

In what circumstances is the reproduction creation unnecessary and when Is representative building suitable?

The code generated by the designer ...


Comments