using System; using System.Collections.Generic; using System.Text; //引用类型 //2、代表 namespace GoodObject { delegate int MyDelegate();//声明一个代表 public class myDelegate { public int instanceMethod() { Console.WriteLine("Call the instance method"); return 0; } static public int staticMethod() { Console.WriteLine("Call the static method"); return 0; } } class StudyDelegate { static void Main(string[] args) { //代表测试测试测试 myDelegate p = new myDelegate(); //将指针指向非静态方法 MyDelegate d = new MyDelegate(p.instanceMethod); d(); //指向静态方法方法方法 d = new MyDelegate(myDelegate.staticMethod); d(); Console.ReadLine(); } } }