Please consider this sample code: It registers a delegate with an event.
p1.FirstNameChanged += new Person.NameChanged(p1_FirstNameChanged);
Now the following code removes the delegate:
p1.FirstNameChanged -= new Person.NameChanged(p1_FirstNameChanged);
The above line that removes the delegate confuses me. It works - buy why
must we use the 'new' keyword? The delegate already exists and is
"registered" with the event. I would think that we would need to somehow get
a reference to an existing delegate or somehow tell the event to remove an
*existing* delegate. It seems to me that the use of the 'new' keyword would
necessarily create a new delegate, and could not possibly obtain any
reference an existing delegate. Yet it works. I'm totally confused.
Thanks!