继续this question。 VB.NET是否支持虚拟事件?
答案 0 :(得分:4)
没有。这是我们考虑支持的东西,但在给定的语言周期中不符合我们当前的标准。
是。您可以使用自定义事件语法来允许层次结构控制的事件。
MustInherit Class Base
Public Custom Event Event1 As EventHandler
AddHandler(ByVal value As EventHandler)
AddEvent1(value)
End AddHandler
RemoveHandler(ByVal value As EventHandler)
RemoveEvent1(value)
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs)
RaiseEvent1(sender, e)
End RaiseEvent
End Event
Protected MustOverride Sub AddEvent1(ByVal value As EventHandler)
Protected MustOverride Sub RemoveEvent1(ByVal value As EventHandler)
Protected MustOverride Sub RaiseEvent1(ByVal sender As Object, ByVal e As EventArgs)
End Class