Anyone see the flaws? It should be noted that you cannot remove anonymous methods from the list of event delegates, I know about it (in fact, it was a conceptual motivation for this).
The goal here is an alternative:
if (onFoo != null) onFoo.Invoke(this, null);
And the code:
public delegate void FooDelegate(object sender, EventArgs e);
public class EventTest
{
public EventTest()
{
onFoo += (p,q) => { };
}
public FireFoo()
{
onFoo.Invoke(this, null);
}
public event FooDelegate onFoo;
}
source
share