Action<string> methodCall = (x) => { x += "haha"; MessageBox.Show(x); }; public event Action<string> BoilerEventLog; private void button2_Click(object sender, EventArgs e) { BoilerEventLog += new Action<string>(methodCall); BoilerEventLog("123"); }MessageBox.Show(x) 换成 Console.WriteLine(x);
static Action<string> methodCall = (x) => { x += "haha"; Console.WriteLine(x); };
public static event Action<string> BoilerEventLog;
static void Main(string[] args)
{
BoilerEventLog += new Action<string>(methodCall);
BoilerEventLog("123");
//Console.WriteLine(x);
Console.ReadKey();
}
这样才可以,可是事件和委托加了static,这样还是不是事件和委托
?
楼上说的没错!