I saw this on another post and have shamelessly stolen it and used it in much of my code ever since:
public delegate void MyClickHandler(object sender, string myValue);
public event MyClickHandler Click = delegate {}; // add empty delegate!
//Let you do this:
public void DoSomething() {
Click(this, "foo");
}
//Instead of this:
public void DoSomething() {
if (Click != null) // Unnecessary!
Click(this, "foo");
}
* If anyone knows the origin of this technique, please post it in the comments. I really do believe in the source getting due credit.
(Edit: I got it from this post Hidden Features of C#?)