【发布时间】:2015-12-03 07:36:49
【问题描述】:
我正在尝试使用网站中给出的确切代码重现 C# compiler error CS0840:
class Test36
{
public int myProp { get; } // CS0840
// to create a read-only property
// try the following line instead
public int myProp2 { get; private set; }
}
public Form1()
{
InitializeComponent();
Test36 test = new Test36();
}
我正在使用 Visual Studio Community 2015 在 .NET 4.0 上运行它。令人惊讶的是,我无法重现它。编译器不会抛出任何错误:
为什么编译器没有抛出任何错误?
【问题讨论】:
标签: c# .net visual-studio compiler-errors visual-studio-2015