Pet*_*ton 14
你去吧
List<Action> list = new List<Action>();
list.Add( () => ClassA.MethodX(paramM) );
list.Add( () => ClassB.MethodY(paramN, ...) );
foreach (Action a in list) {
a.Invoke();
}
Run Code Online (Sandbox Code Playgroud)
是的,可以有这样的数组或列表.根据输入或输出参数的数量,你可以使用类似的东西
List<Func<T1, T2, TReturn>>
Run Code Online (Sandbox Code Playgroud)
类型的实例Func<T1, T2, TReturn>是类似的方法
TReturn MyFunction(T1 input1, T2 input2)
Run Code Online (Sandbox Code Playgroud)