zoukankan      html  css  js  c++  java
  • 事件简单示例


    1
    public partial class TestForm : Form 2 { 3 public TestForm() 4 { 5 InitializeComponent(); 6 } 7 8 private void TestForm_Load(object sender, EventArgs e) 9 { 10 TestClass.testDelegateEvent += new TestClass.TestDelegate(TestClass_testDelegateEvent); //1 11 TestClass tc = new TestClass();//2 12 tc.GetInfo("aaaa");//3 13 } 14 15 public void TestClass_testDelegateEvent(string msg) 16 { 17 msg += "!@#$";//7 18 MessageBox.Show(msg);//8 19 } 20 } 21 22 public class TestClass 23 { 24 public delegate void TestDelegate(string msg); 25 public static event TestDelegate testDelegateEvent; 26 27 public void GetInfo(string msg) 28 { 29 msg += "1234567890";//4 30 if (testDelegateEvent != null)//5 31 testDelegateEvent(msg);//6 32 } 33 }

    C#事件简单示例,//1  //2  ....表示执行顺序

  • 相关阅读:
    第十九周作业
    第十八周作业
    第十七周作业
    第16周作业
    第15周作业
    第14周作业作业
    第13周作业
    第12周作业
    第二阶段月考
    RDB和AOF的区别
  • 原文地址:https://www.cnblogs.com/yf2011/p/3135838.html
Copyright © 2011-2022 走看看