I have a interface that must return Task type.
public interface IStrategy
{
Task Test();
}
And this interface will be called by this line:
IStrategy strategy = StrategyFactory.Generate();
result = await strategy.Test();
And I need to implement it with no-op like this:
Option1
public class NoopStrategy:IStrategy
{
public async Task Test()
{
return await Task.FromResult<obeject>(null);
}
}
or I try to delete asyc, it also work:
Option2
public class NoopStrategy:IStrategy
{
public Task Test()
{
return Task.FromResult<obeject>(null);
}
}
So, I want to know which is better? and what's the different?