Implementing read-only properties with { get; }
问题 Why doesn't this run: class Program { static void Main(string[] args) { Apple a = new Apple("green"); } } class Apple { public string Colour{ get; } public Apple(string colour) { this.Colour = colour; } } 回答1: Your code is valid for C# 6, which comes with Visual Studio 2015. It is not valid for previous versions of the language or Visual Studio. Technically, you can install an old pre-release version of Roslyn in VS 2013 but it isn't worth the trouble now that VS 2015 was released. For this