If I have an event like this:
public delegate void MyEventHandler(object sender, EventArgs e);
public event MyEventHandler MyEvent;
And adds an eventhandler like this:
MyEvent += MyEventHandlerMethod;
… is it then possible to register this somehow? In other words – is it possible to have something like:
MyEvent.OnSubscribe += MySubscriptionHandler;
Similar to auto-implemented properties, events are auto-implemented by default as well.
You can expand the declaration of an
eventas follows:See, for example, How to: Use a Dictionary to Store Event Instances (C# Programming Guide)
See Events get a little overhaul in C# 4, Part I: Locks for how auto-implemented events differ between C# 3 and C# 4.