问题
Until this very day, I could make use of primary constructors, such as:
public class Test(string text)
{
private string mText = text;
}
To be able to do this, in the previous Visual Studio CTP, I had to add this to the csproj-file:
<LangVersion>Experimental</LangVersion>
Anyhow, this no longer works in the Visual Studio 2015 Preview (with or without LangVersion
). Does anyone have any ideas about what could be going on?
回答1:
Does anyone have any ideas about what could be going on?
Yup - primary constructors have been removed from the plans for C# 6. They may well make an appearance in some form in a later version, but they're not in C# 6 any more.
See the "Changes to the language feature set" post from the team for more details.
来源:https://stackoverflow.com/questions/26915789/primary-constructors-no-longer-compile-in-vs2015