我有这个类,将委托定义为函数
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.ComponentModel;<br />
using System.Collections;<br /><br />
namespace ClassLibrary1<br />
{<br />
public delegate bool DrillDownHandler(IComponent control);<br />
public delegate void ComponentLoadedHandler(IComponent control);
public interface interface1
{
event DrillDownHandler DrillDown;
event ComponentLoadedHandler ComponentLoaded;
}
public class Class1 : interface1
{
public Class1()
{
DrillDown += new DrillDownHandler(DrillDownDefault);
}
private ArrayList drillList = new ArrayList();
public event DrillDownHandler DrillDown
{
add
{
drillList.Add(value);
}
remove
{
drillList.Remove(value);
}
}
public event ComponentLoadedHandler ComponentLoaded;
private bool DrillDownDefault(IComponent control)
{
return false;
}
}
}
当转换为 VB.Net 时,我们得到以下代码,但不起作用
<br /><br />
Imports System<br />
Imports System.Collections.Generic<br />
Imports System.Linq<br />
Imports System.Text<br />
Imports System.ComponentModel<br />
Imports System.Collections<br />
<br />
Namespace ClassLibrary1<br />
Public Delegate Function DrillDownHandler(control As IComponent) As Boolean<br />
Public Delegate Sub ComponentLoadedHandler(control As IComponent)<br />
Public Interface interface1
Event DrillDown As DrillDownHandler
Event ComponentLoaded As ComponentLoadedHandler
End Interface
Public Class Class1
Inherits interface1
Public Sub New()
DrillDown += New DrillDownHandler(DrillDownDefault)
End Sub
Private drillList As New ArrayList()
Public Custom Event DrillDown As DrillDownHandler
AddHandler(ByVal value As DrillDownHandler)
drillList.Add(value)
End AddHandler
RemoveHandler(ByVal value As DrillDownHandler)
drillList.Remove(value)
End RemoveHandler
End Event
Public Event ComponentLoaded As ComponentLoadedHandler
Private Function DrillDownDefault(control As IComponent) As Boolean
Return False
End Function
End Class
End Namespace
任何人都可以提供帮助