Unknown new VS.NET 2005 feature – Calling Delegate.Invoke directly

So, at the GNET2 last week, I found out that you can now call Delegate.Invoke instead of using the C# functor syntax.  This makes code much more readable IMO —

delegate void MyCallback(string msg);

MyCallback callback;

callback += delegate(string msg) { Console.WriteLine(msg); };

callback.Invoke(“Hello”);   // instead of callback(“Hello”);

Very nice.

About Mark Smith

Windows systems developer with low-level operating system, threading and .NET experience. For the past several years I have been involved with WPF/Silverlight and most recently iOS and Android. I have worked as an architect and designer for several companies and am particularly interested in client/server and graphical solutions. Specialties:.NET, WPF, Silverlight, Windows, iOS

Latest Blog Posts

Building Windows Store apps with HTML/JS and WinJS

Thanks to everyone who attended the WinJS marathon! Here's the slides and demos we … Read More »

NumericTextBoxBehavior for XAML-based Windows Store Applications

One of the first (and arguably most useful) behaviors that I wrote for MVVMHelpers was a … Read More »