Rob P.
Rob P.

Reputation: 15071

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.

However, when I paste in C# 6.0 code, Resharper asks me if I would like to enable C# 6.0 support. If I allow it, I'm able to compile C# 6.0 code.

        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'. And if I check the dropdown, I can only see up to C# 5.0.

Upvotes: 1

Views: 607

Answers (2)

mnwsmit
mnwsmit

Reputation: 1173

My best guess is that you are using the ReSharper Build Engine (ReSharper -> Options -> Tools -> Build, see Build Engine)

Upvotes: 0

Gabriel Luci
Gabriel Luci

Reputation: 40928

According to this answer, it can work in VS 2012 if you have the 'Microsoft.Net.Compilers' NuGet package installed in your project.

Upvotes: 1

Related Questions