C# removing an event handler

Viewed 55971

I've been doing this for a while, but I haven't noticed that I've been using a new each time I remove an event handler. Am I supposed to be creating a new object?

Basically is there a difference between 1 and 2?

  1. ethernetdevice.PcapOnPacketArrival -= new SharpPcap.PacketArrivalEvent(ArrivalResponseHandler);

  2. ethernetdevice.PcapOnPacketArrival -= ArrivalResponseHandler;

EDIT: Okay this is a duplicate. Sorry about that. Answer posted here.

Two delegates of the same type with the same targets, methods, and invocation lists are considered equal.

2 Answers
Related