简体   繁体   English

主构造函数不再在VS2015中编译

[英]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: 为了能够做到这一点,在以前的Visual Studio CTP中,我不得不将其添加到csproj文件中:

<LangVersion>Experimental</LangVersion>

Anyhow, this no longer works in the Visual Studio 2015 Preview (with or without LangVersion ). 无论如何,这不再适用于Visual Studio 2015 Preview(有或没有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. 是的 - 主要的构造函数已经从C#6的计划中删除了。它们很可能在以后的版本中以某种形式出现,但它们不再是C#6。

See the "Changes to the language feature set" post from the team for more details. 有关详细信息,请参阅团队中的“对语言功能集的更改”帖子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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