Kenichi <no****@nospam.com> wrote:
hello, i'm still new to vs
i have a question,
how can i clear my event like to set that to null ?
You can't clear an event in another object - events themselves *only*
expose ways of subscribing and unsubscribing.
i would like to do something like this without knowing
what is the event handler before
ex: (error)
button1.Click = null;
i know i can clear that manually using such as
button1.Click -= new EventHandler(button1_Click);
but in case there is many event assigned to button1.Click
i think it would be not effecient writing one by one line removing the event
handler is there another way?
Yes, that would probably be more efficient - very, very slightly, in a
way which would be insignificant to virtually all programs. However, it
would break the encapsulation of events.
If you're writing your own class which exposes an event, of course, you
could include a public method of ClearFooEventHandlers which set the
underlying delegate variable to null, if you want.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too