Say I have an asynchronous method:
public async Task DoThing(int x)
{
// ...
}
Now, I want to wrap this method with a new method. Each of these two options are functionally equivalent:
public async Task WrapperOne()
{
await DoThing(6);
}
public Task WrapperTwo()
{
return DoThing(6);
}
This is because C# treats a Task
just like any other object, so it can be passed through, returned, and so on as any object can. In fact, I presume these two methods compile to the same thing (please correct me if this premise is wrong). My question is, from a code readability perspective, which is better? I was not able to find any official guidance about this on Microsoft, but maybe I missed it?