简体   繁体   中英

Primary constructors no longer compile in VS2015

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM