static void Main(string[] args) { TestDelegate(); } //------------------------------------------------------ delegate string SayHi(string name); public static string cn(string name) { return "你好 " + name; } public static string en(string name) { return "hi " + name; } /// <summary> /// 测试 委托(Delegate) /// </summary> public static void TestDelegate() { // 创建委托实例 SayHi sayCN = new SayHi(cn); SayHi sayEN = new SayHi(en); // 使用委托对象调用方法 Console.WriteLine(sayCN("蒋智昊")); Console.WriteLine(sayEN("jzh")); Console.ReadLine(); } //------------------------------------------------------