// 定义(初始化)
System.EventHandler[] handlers = new System.EventHandler[]
{
new System.EventHandler(yourMethod1),
new System.EventHandler(yourMethod2),
new System.EventHandler(yourMethod3),
new System.EventHandler(yourMethod4),
new System.EventHandler(yourMethod5),
...
}// 应用(调用)
foreach (EventHandler h in handlers)
{
h(this, System.EventArgs.Empty);
}
但在C#中一般不用指针,都用委托,可以用委托来实现你的这个要求,public class Demo
{public delegate void YourFunctionHandler();// 下面是一组具有YourFunctionHandler()函数声明的函数,
private void Function1()
{
}private void Function2()
{
}
.
.
.
private void FunctionN()
{
}// N换成具体的数字
private YourFunctionHandler[] FuncPtr=new YourFunctionHandler[N];
public YourFunctionHandler[] Functions
{
get{ return FuncPtr; }
}
private void Demo()
{
FuncPtr[0]=new YourFunctionHandler(Function1);
FuncPtr[1]=new YourFunctionHandler(Function2); .
.
.
FuncPtr[N-1]=new YourFunctionHandler(FunctionN);
} public static void main()
{
Demo demo=new Demo();
// 调用函数数组中的函数
for(int i=0;i<demo.Functions.Length;i++)
{
demo.Functions[i]();
}
} }