“RaiseEvent”方法和包含事件的委托类型“<signature>”必须有相同的签名
Custom Event
声明必须具有 RaiseEvent
声明,此声明具有和自定义事件的 As
子句指定的委托类型相同的签名。
对于要匹配的签名, RaiseEvent
声明和委托必须具有参数数量,并且参数类型必须匹配。
错误 ID: BC31137
- 更改
RaiseEvent
声明的参数以匹配委托类型的参数。
此示例演示具有 RaiseEvent
声明的正确参数类型的自定义事件。
VB
Delegate Sub TestDelegate(ByVal sender As Object, ByVal i As Integer)
Custom Event Test As TestDelegate
AddHandler(ByVal value As TestDelegate)
' Code for adding an event handler goes here.
End AddHandler
RemoveHandler(ByVal value As TestDelegate)
' Code for removing an event handler goes here.
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal i As Integer)
' Code for raising an event goes here.
End RaiseEvent
End Event