What do I return from D4()
?
async static Task D4()
{
Console.Write("Enter the divisor: ");
var n = int.Parse(Console.ReadLine());
Console.WriteLine((24 / n).ToString());
// NONE OF THESE WORK
// THE COMPILER COMPLAINS WITH AN ERROR THAT SAYS:
// Since 'Program.D4()' is an async method that returns 'Task',
// a return keyword must not be followed by an object expression.
// Did you intend to return 'Task<T>'?
// return new TaskCompletionSource<object>().Task;
// return Task.FromResult<object>(null);
// return Task.FromResult<bool>(false);
// return Task.FromResult(0);
}
I asked something similar earlier and it probably worked in my situation then but I have no recollection of the situation now. Also, this thread seems to suggest the same thing that I am trying. I am not sure why it doesn't work in my case.
UPDATE
For the sake of completeness, here is the whole of the relevant bit of code.
async static Task A4() { await B4(); }
async static Task B4() { await C4(); }
async static Task C4() { await D4(); }
async static Task D4()
{
Console.Write("Enter the divisor: ");
var n = int.Parse(Console.ReadLine());
Console.WriteLine((24 / n).ToString());
// return new TaskCompletionSource<object>().Task;
// return Task.FromResult<object>(null);
// return Task.FromResult<bool>(false);
// return Task.FromResult(0);
}