using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { // 实例化按钮对象 Button button1 = new Button(); // 加载点击方法 button1.onClick += new Button.Click(button1_Click); // 触发点击事件 button1.ArouseClick(); Console.ReadLine(); } /// <summary> /// 激发按钮的点击事件 /// </summary> /// <param name="sender">sender 激发事件对象</param> /// <param name="e">e 激发事件对象信息</param> private static void button1_Click(object sender, ButtonEventArgs e) { Console.WriteLine("激发按钮的点击事件"); Console.WriteLine(e.buttonMessage); Console.WriteLine(sender.GetType()); } } /// <summary> /// 构建按钮类 /// </summary> public class Button { // 创建一个委托 public delegate void Click(object sender, ButtonEventArgs e); // 声明一个事件 public event Click onClick; // 触发事件 public void ArouseClick() { Console.WriteLine("调用按钮的点击事件"); onClick(this ,new ButtonEventArgs("按钮的信息")); } } /// <summary> /// 创建存储激发事件对象的信息 /// </summary> public class ButtonEventArgs : EventArgs { public string buttonMessage; public ButtonEventArgs(string buttonMessage) { this.buttonMessage = buttonMessage; } } } 我是一个初学者 有很多不足的地方 还请大虾们多多指点