Event handling mechanism often requires registration and canceling event subscribers. When registering with the naming method, the cancellation process is very simple. However, when using anonymous methods, the cancellation seems not so obvious.
Question:
Can I cancel anonymous in the event in C#?
Answer:
Yes, you can cancel the anonymous method from the event. The method is as follows: By retaining the reference to the commission, you can use it to cancel the anonymous method in the event later.
The above is the detailed content of How to Unsubscribe Anonymous Event Handlers in C#?. For more information, please follow other related articles on the PHP Chinese website!