Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
 public async Task<Tuple<List<int>, bool>> GetQuestionOptions(List<studs> studsList)
{
//code
return new Tuple<List<int>, bool>(new List<int>(), true);
}


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
Posted
Updated 6-Sep-16 22:04pm

Returning a simple result asynchronously is a pain.
Following code compiles:
C#
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);
}

The magic is in return await Task.FromResult.
 
Share this answer
 
Comments
madhukrishnahere 1-Jan-17 22:47pm    
Thank you
 
Share this answer
 
Comments
CPallini 7-Sep-16 2:42am    
5.
Mehdi Gholam 7-Sep-16 9:37am    
Thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900