I was looking at this question and while I think I mostly understand event accessors two other aspects of this confused me.
First:
private event Action<int> ActivityChanged = delegate {};
Was this event assigned a value with variable-initializers, my understanding was that only += and -= operators were permmited on events? What does the anonymous method do here?
Second:
event Action<int> IActivityFacade.ActivityChanged
{
add
{
ActivityChanged += value;
value(GetSelectedActivity());
}
remove { ActivityChanged -= value; }
}
Was the first line a forward declaration and the second a definition? I come from a C++/C background and that is what this appeared to me but for all I know it could mean something else entirely. Are forward declarations even allowed in C#