Do this:
public delegate void TestEventHandler();
public static event TestEventHandler OnTestEvent = delegate{};
At that point, you an just call
OnTestEvent()
ewithout the
if
block.
By the way, you really should have - at the VERY least) the following parameters (even if you don't use them right away):
public delegate void TestEventHandler(object sender, EventArgs e);
In fact, your *should* define your own
MyEventArgs
class (must inherit from
EventArgs
) so that you can pass parameters to the event handler.