在VB.NET中你有声明:
AddHandler object As Event, object As Delegate
我需要能够在运行时激活和停用处理程序,所以我想要类似于此的东西:
Class EventHandler
Private mEvent as Event
Private mDelegate As Delegate
Public Sub New(evt As Event, del as Delegate)
mEvent=evt
mDeletate=del
End Sub
Public Sub Activate
AddHandler mEvent, Delegate
End Sub
Public Sub Deactivate
RemoveHandler mEvent, Delegate
End Sub
End Class
这可能吗?