C# event handler delegate changed according to C# versions.
Here is a sample, based on UnhandledException event
in the beginning was
d.UnhandledException += new UnhandledExceptionEventHandler(d_UnhandledException); //... void d_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine("Ouch!"); }
currently, lambda version is quicker to write and easier to understand
d.UnhandledException += (sender, e) => { Console.WriteLine("Ouch!"); };
ain’t it ? 😉
Maybe Visual Studio Intellisense helps you with old style form, and you have to write the full version manually (do you snippet ?).
In Initializing things in C# post I found a quick reference to event handler, anonymous type, lambda, object initialization, etc
with clearfull samples according to C# versions 1, 2 and 3.
Have a nice reading 😉
Technorati tags: CSharp, Lambda, Delegate