在C#中,我可以這樣做:VB.NET:我如何讓事件返回一個值,就像我可以在C#中一樣?
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Class1 c1 = new Class1();
c1.OnNeedInt += new Class1.NeedInt(c1_OnNeedInt);
int i = c1.GetInt();
}
int c1_OnNeedInt()
{
return 1;
}
}
public class Class1
{
public delegate int NeedInt();
public event NeedInt OnNeedInt;
public int GetInt()
{
return OnNeedInt == null ? 0 : OnNeedInt();
}
}
通知行int i = c1.GetInt();
。我似乎無法讓VB.NET 4.0做類似的事情。任何幫助?