Primary constructors no longer compile in VS2015

坚强是说给别人听的谎言 提交于 2020-01-18 16:23:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!