5.1.1 订阅三个按钮事件
static void LogPlainEvent(object sender, EventArgs e) { Console.WriteLine("LogPlain"); } static void LogKeyEvent(object sender, KeyPressEventArgs e) { Console.WriteLine("LogKey"); } static void LogMouseEvent(object sender, MouseEventArgs e) { Console.WriteLine("LogMouse"); } static void Main(string[] args) { Button button1 = new Button(); button1.Text = "Click me"; button1.Click+=new EventHandler(LogPlainEvent); button1.KeyPress+=new KeyPressEventHandler(LogKeyEvent); button1 .MouseClick+=new MouseEventHandler(LogMouseEvent); Form form1 = new Form(); form1.AutoSize = true; form1.Controls.Add(button1); Application.Run(form1); }