简体   繁体   English

Resharper的“已启用C#6.0功能”在Visual Studio 2012中如何工作?

[英]How Does Resharper's 'Enabled C# 6.0 Features' Work in Visual Studio 2012?

I've been told that C# 6.0 is not going to be supported by Visual Studio 2012 and that to compile C# 6.0 code, I would need to upgrade to a newer version of Visual Studio. 有人告诉我Visual Studio 2012将不支持C#6.0,并且要编译C#6.0代码,我需要升级到Visual Studio的较新版本。

However, when I paste in C# 6.0 code, Resharper asks me if I would like to enable C# 6.0 support. 但是,当我粘贴C#6.0代码时,Resharper询问我是否要启用C#6.0支持。 If I allow it, I'm able to compile C# 6.0 code. 如果允许,我可以编译C#6.0代码。

        List<string> customers = null;
        string Customer;

        int? length = customers?.Count; 
        Customer = customers?[0];      

It seems to work, but can anyone explain how it's working? 它似乎有效,但是谁能解释它的工作原理?

If I go into the project's properties / Build / Advanced... the 'Language version' is set to 'default'. 如果我进入项目的属性/ Build / Advanced ...,则“语言版本”设置为“默认”。 And if I check the dropdown, I can only see up to C# 5.0. 而且,如果我检查下拉列表,则最多只能看到C#5.0。

根据此答案 ,如果您在项目中安装了“ Microsoft.Net.Compilers” NuGet软件包,则它可以在VS 2012中工作。

我最好的猜测是您正在使用ReSharper Build Engine(ReSharper->选项->工具-> Build,请参阅Build Engine)

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

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