The code is just an operator, similar to a method call, and thus occurs in the natural flow of execution in the place where you placed it, whether inside the loop, if-statement or the like.
Thus, before the statement is executed, the event handler is not assigned to the event. It does not matter (in this context) whether the event is a static or an instance event.
You can think about how the code works by comparing it with this code:
some_event = Delegate.Combine(some_event, some_event_handler);
then it should be clearer that this is just a call to the main method, nothing more.
The syntax event += handler is just brief for the above code, and the compiler will translate the syntax of this method call. If you use Reflector , you can see that it is done like that.
See Delegate.Combine on MSDN.
Lasse Vågsæther Karlsen
source share