Digging through some old code, I have noticed a call to an asyncmethod and then a check for the task being returned for null.
async Task<Something> DoSomeStuffAsync()
{
//...
return null; //not the actual return, but I guess it doesn't matter
}
var result = DoSomeStuffAsync(); //without await
if(result == null)
{
//does this part makes any sense
}
From my understanding of the async keyword, this scenario will never be possible because the result of an async method will always be wrapped in a Task but just to check, am I missing something?
Is there any case when an async method will return null in C#?