c#中如何把多个方法放入数组

 时间:2024-10-12 17:02:45

1、// 1、定义一个委托 TestDelegate delegate void TestDelegate(string text);

2、设置好几个函数static void MothedA(string text) { MessageBox.Show("方法A:" + text); } static void MothedB(string text) { MessageBox.Show("方法B:" + text); } static void MothedC(string text) { MessageBox.Show("方法C:" + text); }

3、public void Start猾诮沓靥() { //2、定义委托数组 TestDelegate[] array = new TestDelegate[3]; // 3、建立委托数字,将方法MothedA,MothedB,MothedC放入数组中 array[0] = new TestDelegate(MothedA); array[1] = new TestDelegate(MothedB); array[2] = new TestDelegate(MothedC); // 4、从数组中就可以方便调用方法了 array[0]("中国"); array[1]("日本"); array[2]("美国"); }

c#中如何把多个方法放入数组
  • 房主去世的房产如何办理继承公证?
  • 怎么成为一名优秀的服饰陈列师
  • 排卵期后下腹部疼痛怎么办
  • 旅行青蛙没有四叶草怎么办
  • 热门搜索
    诚信友善手抄报 成语故事手抄报 绿色家园手抄报内容 欢庆元旦手抄报 5.1劳动节手抄报 清明节手抄报一年级 尊师重教手抄报 祝福祖国手抄报 推广普通话手抄报内容 劳动节手抄报简单一点