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

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

问题描述

直到今天,我可以利用的主要构造,如:

 公共类测试(字符串文本)
{
    私人字符串MTEXT =文本;
}

要能够做到这一点,在previous Visual Studio的CTP,我不得不把它添加到的csproj文件:

 < LangVersion>实验< / LangVersion>

总之,这不再是在Visual Studio 2015 preVIEW工作(带或不带 LangVersion )。有没有人有什么可以去任何想法?


解决方案

  

有没有人有什么可以去任何想法?


是的 - 主要构造已经从计划C#6,他们很可能以某种形式在以后的版本外观删除,但他们不是在C#6更多的

查看更改设置语言功能从团队发布更多的细节。

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.

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

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