I\'ve just been playing around with async/await and found out something interesting. Take a look at the examples below:
// 1) ok - obvious
public Task
Task is simply not a covariant type.
Although List can be converted to IEnumerable, Task cannot be converted to >
Task. And In #4, Task.FromResult(doctors) returns Task.>
In #3, we have:
return await Task.FromResult(doctors)
Which is the same as:
return await Task.FromResult>(doctors)
Which is the same as:
List result = await Task.FromResult>(doctors);
return result;
This works because List can be converted IEnumerable.