我已经安装了新版本的 Visual Studio 并将项目设置为 C# 8。当我尝试使用如下所示的新界面功能时,它说我无法在界面中实现,这似乎不知何故我无法使用新功能。谁能解释一下为什么,它仍然没有包含在 2019 年预览中吗?
interface IDefaultInterfaceMethod
{
public void DefaultMethod()
{
Console.WriteLine("I am a default method in the interface!");
}
}
最佳答案
基于this :
Microsoft has fleshed out more details about C# Version 8.0, the next planned major release of the language. C# 8.0 is expected to arrive in 2019, concurrent with the arrival of .Net Core 3.0.
所有 C# 8 功能仍处于开发早期,可能会发生变化。因此,最好等到这些功能最终发布。以下博客也可能有所帮助:
Any estimation for C# 8.0 release date?
并非所有 C# 8.0 功能均可用(Visual Studio 2019 预览版 1)。您可以在以下链接中找到当前可用功能的列表:
关于c# - 无法使用接口(interface)默认方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53694961/