C# 8.0 - Can't use default interface implementations

13.5k Views Asked by At

I recently read about C# 8.0 having interface default implementations, so i went into my project and tried it out, but i was met with an error instead. Target runtime doesn't support default interface implementation. Is there any way to fix this issue?

string CommandName { get => CommandName.ToUpperInvariant(); }

Edit I am using Console

1

There are 1 best solutions below

0
On BEST ANSWER

Did you check your runtime version? C# 8.0 is supported on .NET Core 3.x and .NET Standard 2.1.


UPDATE:

Thanks to Microsoft's confusing naming and versioning, the latest version of .NET SDK is called .NET x.x, but it's just like a new version of .NET Core--it's cross-platform and can target different runtimes.

C# 9.0 is the default language version since .NET 5.x (the latest version at the moment). You can check the default language version for different runtimes and how to configure the version here.