一个例子:
class SpecialButton
{
public SpecialButton(ButtonConfig conf, Method definedMethod)
{
button = new Button();
button.Location = conf.Location;
//etc.
button.Click += new System.EventHandler(definedMethod);
}
}
是否可以将变量定义为方法?我想对来自此类外部的此点击事件使用委托(delegate)。
谢谢。
请您参考如下方法:
我会使用 Action<Object, EventArgs>或者只是 EventHandler .
