Is there a way to overload the event += and -= operators in C#? What I want to do is take an event listener and register it to different events. So something like this:
SomeEvent += new Event(EventMethod);
Then instead of attaching to SomeEvent, it actually attaches to different events:
DifferentEvent += (the listener above);
AnotherDiffEvent += (the listener above);
Thanks
It's not really overloading, but here is how you do it:
public event MyDelegate SomeEvent
{
add
{
DifferentEvent += value;
AnotherDiffEvent += value;
}
remove
{
DifferentEvent -= value;
AnotherDiffEvent-= value;
}
}
More information on this on switchonthecode.com