My question is two parts -
First, we can attach event handlers in two ways:
myObject.MyEvent += new EventHandler(MyHandler);
myObject.MyEvent += MyHandler;
In my understanding, these two are equivalent. In the second case, the C # compiler performs the task of creating an instance of the delegate from the corresponding overload from the specified method group. It's right?
Secondly, is there a difference between the two corresponding handler detach styles? If so, what is it?
myObject.MyEvent -= new EventHandler(MyHandler);
myObject.MyEvent -= MyHandler;
source
share