如何返回任务< tuple< list< int> ;, bool> ?
问题描述:
public async Task<Tuple<List<int>, bool>> GetQuestionOptions(List<studs> studsList)
{
//code
return new Tuple<List<int>, bool>(new List<int>(), true);
}
我的尝试:
编译错误异步方法的返回类型必须为void,任务或任务< t> ??
请帮帮我。
谢谢
What I have tried:
Compilation error "The return type of an async method must be void, Task or Task<t>" ??
Please help me out.
Thanks
答
异步返回一个简单的结果很痛苦。
以下代码编译:
Returning a simple result asynchronously is a pain.
Following code compiles:
public async Task<Tuple<List<int>, bool>> GetQuestionOptions(List<studs> studsList)
{
var tmp = new Tuple<List<int>, bool>(new List<int>(), true);
return await Task.FromResult(tmp);
}
魔法在返回await Task.FromResult
。
阅读: c# - 异步方法的返回类型必须为void,Task或Task& lt; T& gt; - 堆栈溢出 [ ^ ]