Is there a downside to adding an anonymous empty delegate on event declaration?

Posted by serg10 on Stack Overflow See other posts from Stack Overflow or by serg10
Published on 2008-10-04T19:41:15Z Indexed on 2010/04/04 5:23 UTC
Read the original article Hit count: 275

Filed under:
|
|
|
|

I have seen a few mentions of this idiom (including on SO):

// Deliberately empty subscriber
public event EventHandler AskQuestion = delegate {};

The upside is clear - it avoids the need to check for null before raising the event.

However, I am keen to understand if there are any downsides. For example, is it something that is in widespread use and is transparent enough that it won't cause a maintenance headache? Is there any appreciable performance hit of the empty event subscriber call?

© Stack Overflow or respective owner

Related posts about c#

Related posts about event