namespace WinFormsApp2
{delegate void ShowName(object sender);//声明委托类型,委托类型可以理解为一类方法的类型 ,如此处的showbuttonname方法便是符合showName类型public partial class Form1 : Form{private event ShowName btnclick; //声明事件,此处相当于实例化委托类型,用于后面调用public Form1(){InitializeComponent();btnclick += ShowButtonName; //订阅事件}private void button1_Click(object sender, EventArgs e){MessageBox.Show("我被点击了!!!");btnclick(sender); //此处方法相当与执行订阅的 ShowButtonName方法}private void ShowButtonName(object sender){Button btn=sender as Button;if(btn !=null){MessageBox.Show("按钮名称是:" + btn.Text);}}}}