Roc*_*cky 1 c# lambda delegates
我一直试图解决这个问题,这真的让我烦恼.我有一些看起来像这样的代码
static T MyFunction<T>(Func<T> action, int i, int i2)
{
...some code here
}
Run Code Online (Sandbox Code Playgroud)
当我需要调用此代码时,我尝试了这个
var result = MyFunction<List<string>>(MethodThatReturnsListofString(int number), 1,2)
Run Code Online (Sandbox Code Playgroud)
它失败说明最佳重载具有无效参数但是当我尝试以下操作时
var result = MyFunction<List<string>>(() => MethodThatReturnsListofString(int number), 1,2)
Run Code Online (Sandbox Code Playgroud)
它工作正常.在这种情况下,"()=>"的功能是什么.我认为()不能用于需要超过0 args的方法.