小弟初学C#,有一程序不解!望达人解答!
程序:
1 using System;
2 class UserInputMonitor
3 {
4 public delegate void UserRequest(object sender,EventArgs e);
5 public event UserRequest OnUserRequest;
6 public void Run()
7 {
8 if (Console.ReadLine()=="h")
9 OnUserRequest(this,new EventArgs());
10 }
11 }
12 public class Client
13 {
14 public static void Main()
15 {
16 UserInputMonitor monitor=new UserInputMonitor();
17 new Client(monitor);
18 monitor.Run();
19 }
20 private void ShowMessage(object sender,EventArgs e)
21 {
22 Console.WriteLine("HaHa!!");
23 }
24 Client(UserInputMonitor m)
25 {
26 m.OnUserRequest+=new UserInputMonitor.UserRequest(this.ShowMessage);
27 }
28 }
这是一个事件处理程序,用来监听键盘的输入.
我想把24,25,26,27行去掉,改动一下第17行,可以怎么改?