VB.NET是否支持虚拟事件?

时间:2009-04-03 18:10:50

标签: vb.net events compiler-construction

继续this question。 VB.NET是否支持虚拟事件?

1 个答案:

答案 0 :(得分:4)

VB是否支持虚拟事件的CLR概念

没有。这是我们考虑支持的东西,但在给定的语言周期中不符合我们当前的标准。

VB是否支持自定义事件的层次结构

是。您可以使用自定义事件语法来允许层次结构控制的事件。

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