我正在尝试创建一个接受不同方法Func
作为参数的方法。
我在定义Func
s 参数时遇到了一个小问题。假设我需要调用这样的东西:
public static void SomeTestMethod(int number,string str)
{
Check(MethodOne(number,str));
}
为了检查我有这个:
public static int Check(Func<int,string,int> method)
{
// some conditions
method(where should i get the arguments ?);
}
现在我的问题是我应该如何设置所需的参数?我觉得为 Check 提供单独的参数并不优雅,因为我需要使用我在 TestMethod 中提供的签名来调用 Check。
我不想拥有
Check(MethodOne,arg1,arg2,etc));
如果可能,我需要提供此签名:
Check(MethodOne(number,str));