On line 25, we have
public delegate void OnEvent();
I understand that the ‘void’ and the ‘()’ are used to sign the function delegate prototype. But I don’t understand why it needs to be public? Afterall, on the following line, 26, we have another public class member
public OnEvent onEventObservers;
to instantiate an observer set. Since this onEventObservers observer set is public, other classes can happily subscribe to it. So is there any good reason to leave OnEvent as public too?
I played around and googled a bit and learned that apparently C# demands that events are only as accessible as the delegate associated with it.
I suppose part of my confusion is why we have two lines at all: surely the compiler could read something like
public delegate RETURN_TYPE onEventObservers(INPUT_SIGNATURE_TUPLE);
and bypass the auxillary OnEvent thing all together. Is this not possible for some deep reason?