下面的 C# 代码public async Task<T> GetValueOrCreateAsync<T>(string key, Func<T> factory)
{ //..
var value = await factory();
}编译时会报错CS1061 'Func<T>' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'Func<T>' could be found (are you missing a using directive or an assembly reference?)
1 回答

慕哥9229398
TA贡献1877条经验 获得超6个赞
public async Task<T> GetValueOrCreateAsync<T>(string key, Func<Task<T>> factory) { //.. var value = await factory(); return default(T); }
Func<T> - > Func<Task<T>>
- 1 回答
- 0 关注
- 756 浏览
添加回答
举报
0/150
提交
取消