.net alternatives

by Michel Grootjans
posts - 66, comments - 121, trackbacks - 1

My Links

News

Shelfari: Book reviews on your book blog

Twitter












Archives

Post Categories

January 2009 Entries

Elegant way to raise an event
I got fed up with this kind of code for a long time: private void personList_DoubleClick(object sender, EventArgs e) { if (ShowSelectedPerson != null) ShowSelectedPerson(this, EventArgs.Empty); } Today, a colleague of mine triggered this simple idea: private void personList_DoubleClick(object sender, EventArgs e) { ShowSelectedPerson.Raise(this, EventArgs.Empty); } This is implemented with a simple extension method public static class EventHandlerExtensions { public static void Raise(this EventHandler...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, January 19, 2009 1:24 PM | Feedback (5) |

Powered by: