c# - Difference between wiring events with and without "new" -


in c#, difference (if any) between these 2 lines of code?

tmrmain.elapsed += new elapsedeventhandler(tmrmain_tick); 

and

tmrmain.elapsed += tmrmain_tick; 

both appear work same. c# assume mean former when type latter?

i did this

static void hook1() {     someevent += new eventhandler( program_someevent ); }  static void hook2() {     someevent += program_someevent; } 

and ran ildasm on code.
generated msil same.

so answer question, yes same thing.
compiler inferring want someevent += new eventhandler( program_someevent );
-- can see creating new eventhandler object in both cases in msil


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -