技术开发 频道

c# 中的delegate


【IT168技术文档】


class Program 2 { 3 public delegate void MyDelegate(String name); //声明代理 4 5 public static void MyDelegateFunc(String name) 6 { 7 System.Console.WriteLine("hello:" + name); 8 } 9 static void Main(string[] args) 10 { 11 MyDelegate m = new MyDelegate(MyDelegateFunc); //创建代理对象 12 m("snow"); //调用代理 13 System.Console.Read(); 14 } 15 }
0
相关文章