我想做这样的事情
int x = 2;
int y = 3;
int performAction(int var1, int var2) {
return var1 + var2;
}
//accepts function with parameters as parameter
void runLater(performAction(x, y));
在运行performAction
之前,x和y的值可能会发生变化。
答案 0 :(得分:0)
签名为:
void runLater(Func<int, int, int> functionParameter);
您将完全按照问题中的上方所示来称呼它;
runLater(performAction);
如果需要执行runLater
之外提供的参数:
// signature would be:
void runLater(Func<int> functionParameter);
// invocation like:
var x = 2;
var y = 3;
runLater(delegate () { return performAction(x, y);});
// or
runLater(() => performAction(x, y));