It goes a little bit beyond that, and has it's roots in how delegates
are handled.
When you attach a delegate to an event handler, the delegate at the end
of the list ends up being assigned the reference to the delegate that is
being attached. Your invocation list is actually a linked list.
So, when you use += to attach a delegate to an event handler, it kind of
makes sense when you expand it now to event = event + new delegate, because
what is happening is that you are taking the invocation list, and adding the
event handler to the end of the invocation list.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:ub****************@TK2MSFTNGP12.phx.gbl...
"Beth" <sc***********@msn.com> wrote in message
news:OQ*************@tk2msftngp13.phx.gbl... in the following:
this.ExitButton.Click += new System.EventHandler(this.ExitButton_Click);
if I saw an equation, such as y +=x;
then y = y+x.
But what is the meaning in the event handler. I realize it is adding an
event handler for the click event of the exit button, but how do i reason
through the 2 step process inferred by the += equation.
+= with events means add an event handler to the set. It is basically a
specialization of hte += operator to hook up event handlers, unlike the
equation y = y+x, += just specifcally means "hook up this handler to the
event." It calls the add handler for the event. There isn't a Click =
Click + Handler because it isn't possible to assign to an event from
outside of the class.
If I understand waht you are asking, anyway.