using System;
delegate int Mydelegate();
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 ();
//将指针指向非静态的方法InstanceMethod
Mydelegate d=new Mydelegate (p.InstanceMethod );
//调用非静态方法
d();
//将代表指向静态的方法StaticMethod;
d=new Mydelegate (MyClass.StaticMethod );
//调用静态方法
d();
}
}