Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
The
The remove
contextual keyword is used to define a custom event accessor that is invoked when client code unsubscribes from your event. If you supply a custom remove
accessor, you must also supply an add accessor.
The following example shows an event with custom add and remove
accessors. For the full example, see How to implement interface events.
class Events : IDrawingObject
{
event EventHandler PreDrawEvent;
event EventHandler IDrawingObject.OnDraw
{
add => PreDrawEvent += value;
remove => PreDrawEvent -= value;
}
}
You don't typically need to provide your own custom event accessors. The automatically generated accessors when you declare an event are sufficient for most scenarios. Beginning with C# 14, you can declare partial
events. The implementing declaration of a partial event must declare the add
and remove
handlers.