What is the replacement of Out keyword for Async methods in .Net 4.5 and 4.0?
.net-4.5, async-await, c#, out, windows-phone-8
Solution
You can declare the async function to return `Tuple` instead. With that the function still able to return multiple values without using `out` parameter.
public async Task<Tuple<string, int, bool>>SomeFunctionAsync()
{
return new Tuple<string, int, bool>("foo", 0, false);
}
For Reference :
- Tuple Class
- Why async methods cannot have ref or out parameters?
UPDATE :
you can use shorter syntax as suggested by @svick in comment. Following function return the same value, but using `Tuple.Create` :
public async Task<Tuple<string, int, bool>>SomeFunctionAsync()
{
return Tuple.Create("foo", 0, false);
}
Problem
All i want to use Out keyword with my Async function. According to MSDN it is not possible Async modifiers not supports to the out keyword. So is there any alternate in .Net framework 4.5/4.0 ?