主构造函数不再在 VS2015 中编译 [英] Primary constructors no longer compile in VS2015

查看:23
本文介绍了主构造函数不再在 VS2015 中编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到今天,我都可以使用主构造函数,例如:

Until this very day, I could make use of primary constructors, such as:

public class Test(string text)
{
    private string mText = text;
}

为了能够做到这一点,在以前的 Visual Studio CTP 中,我不得不将其添加到 csproj 文件中:

To be able to do this, in the previous Visual Studio CTP, I had to add this to the csproj-file:

<LangVersion>Experimental</LangVersion>

无论如何,这不再适用于 Visual Studio 2015 预览版(有或没有 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?

是的 - 主要构造函数已从 C# 6 的计划中删除.它们很可能会在更高版本中以某种形式出现,但它们不再出现在 C# 6 中.

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.

这篇关于主构造函数不再在 VS2015 中编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆