C
cannedluncheonmeatobfuscator
After confirming that it really is appropriate to use the "new"
keyword to remove an event handler, as in:
myButton.Click -= new EventHandler(myButton_Click);
I have to ask... how does this compile? I've seen code samples that
store a reference to the event handler in a member variable, then use
the member variable to remove the handler from the event:
myButton.Click -= myHandler;
That seems much more intuitive, so I'm wondering what I get by using
the "new" keyword instead. Are C# delegates inherently pseudo-
singleton (one instance per target method)?
Thanks,
cs
keyword to remove an event handler, as in:
myButton.Click -= new EventHandler(myButton_Click);
I have to ask... how does this compile? I've seen code samples that
store a reference to the event handler in a member variable, then use
the member variable to remove the handler from the event:
myButton.Click -= myHandler;
That seems much more intuitive, so I'm wondering what I get by using
the "new" keyword instead. Are C# delegates inherently pseudo-
singleton (one instance per target method)?
Thanks,
cs