I have a base class that defines an abstract method that returns a Task.
public abstract class BaseClass
{
public abstract Task DoSomething();
}
I can make a class that implements the abstract method in these two different ways.
public class Example1 : BaseClass
{
public override Task DoSomething()
{
return Task.CompletedTask;
}
}
or like this
public class Example2 : BaseClass
{
public override async Task DoSomething()
{
}
}
Notice that the first returns a completed task, the second includes the async keyword and doesn't have a return statement. Is there any difference between the two?