using System;
delegate int MyDeledate();//声明一个代表
public class MyClass
{
public int InstanceMethod(){
Console.WriteLine("Call the instance method.");
return 0;
}
static public int StaticMethod(){
Console.WriteLine("Call the static method.");
return 0;
}
}
public class Test
{
static public void Main()
{
MyClass p=new MyClass();
MyDeledate d=new MyDeledate(p.InstanceMethod);//将代表指向非静态的方法
d();//调用静态方法
d=new MyDeledate(MyClass.StaticMethod);//将代表指向静态的方法
d();//调用静态方法
}
}