Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# 8.0 - Can't use default interface implementations

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

like image 872
AndrewToasterr Avatar asked Dec 07 '19 12:12

AndrewToasterr


1 Answers

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.

like image 94
Lee Avatar answered Sep 22 '22 15:09

Lee