我目前有一个声明如下的页面:
public partial class MyPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//snip
MyButton.Click += (o, i) =>
{
//snip
}
}
}
Run Code Online (Sandbox Code Playgroud)
我最近才从1.1迁移到.NET 3.5,所以我习惯在Page_Load之外编写事件处理程序.我的问题是; 在使用lambda方法时,我应该注意哪些性能缺陷或缺陷?我更喜欢它,因为它当然更简洁,但我不想牺牲性能来使用它.谢谢.
我有
class A
{
B b;
//call this Method when b.Button_click or b.someMethod is launched
private void MyMethod()
{
}
??
}
Class B
{
//here i.e. a button is pressed and in Class A
//i want to call also MyMethod() in Class A after the button is pressed
private void Button_Click(object o, EventArgs s)
{
SomeMethod();
}
public void SomeMethod()
{
}
??
}
Run Code Online (Sandbox Code Playgroud)
A类有一个B类实例.
如何才能做到这一点?