J
jehugaleahsa
Hello:
Say you have a simple class:
public class MyClass { public void DoSomething(object sender,
EventArgs e) {} }
You register the event like this:
MyClass myClass = new MyClass();
someEvent += new EventHandler(myClass.DoSomething);
Can you unregister the event like this?
someEvent -= new EventHandler(myClass.DoSomething);
or do you have to reuse the exact same instance of the delegate?
I just hate creating delegate variables just so I can unregister them
later. I am making sure they are necessary.
Say you have a simple class:
public class MyClass { public void DoSomething(object sender,
EventArgs e) {} }
You register the event like this:
MyClass myClass = new MyClass();
someEvent += new EventHandler(myClass.DoSomething);
Can you unregister the event like this?
someEvent -= new EventHandler(myClass.DoSomething);
or do you have to reuse the exact same instance of the delegate?
I just hate creating delegate variables just so I can unregister them
later. I am making sure they are necessary.