I'm following a course on PluralSight in how to develop a fullstack project in .NET core and have had countless errors that SO and some sweet Google-fu has helped me understand (mainly due to VS version differences).
However I've just encountered something a bit more... complex? I'm working in an interface IWorldRepository
that has this method:
public interface IWorldRepository
{
async Task<bool> SaveChangesAsync(); // <-- error occurs here
}
Which interfaces a class (WorldRepository
) with this method in it:
public async Task<bool> SaveChangesAsync()
{
return (await _context.SaveChangesAsync()) > 0;
}
From my experience with .NET this should work fine, but for some reason the interface is complaining about it, saying: "The modifier 'async' is not valid for this item."
I looked around for the error and found an explanation by our dear Jon Skeet. However I'm not really understanding what might be going on and why my code is erroneous.
Not only does it look OK, but it seems to work fine for the instructor who is running the same code on PluralSight.
I'd be very grateful if someone might be able to shed some light on this!