我有以下VB.Net代码我试图修复:
Public Delegate Sub RequestHandler(ByVal sender As Object, ByVal e As ManageEventArgs)
Public Custom Event RequestEvent As RequestHandler
AddHandler(value As RequestHandler)
End AddHandler
RemoveHandler(value As RequestHandler)
End RemoveHandler
RaiseEvent(sender As Object, e As ManageEventArgs)
End RaiseEvent
End Event
Public Function Request(ByVal bizID As String, ByVal Optional table As Hashtable = Nothing) As ArrayList
Me.aList = New ArrayList
If (Not Me.RequestEvent Is Nothing) Then
Dim e As New ManageEventArgs(bizID, table)
Me.RequestEvent.Invoke(Me, e)
End If
Return Me.aList
End Function
我收到以下错误:
Error BC32022 'Public Event RequestEvent As Manage.RequestHandler' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
VB.Net不是我的首选语言,所以任何帮助都会受到赞赏
答案 0 :(得分:1)
更简单的方法:
Public Event RequestEvent(sender As Object, e As ManageEventArgs)
然后:
Public Function Request(bizID As String, Optional table As Hashtable = Nothing) As ArrayList
Dim aList As New ArrayList
RaiseEvent RequestEvent(Me, New ManageEventArgs(bizID, table))
Return aList
End Function
我不确定您的aList thingy会发生什么。