1

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.

Rob P.
  • 14,921
  • 14
  • 73
  • 109

2 Answers2

1

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

Community
  • 1
  • 1
Gabriel Luci
  • 38,328
  • 4
  • 55
  • 84
  • I'm able to build C# 6.0 code in Visual Studio 2012 without installing any NuGet packages - but I don't understand how it's working? – Rob P. Dec 21 '15 at 20:30
0

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

mnwsmit
  • 1,198
  • 2
  • 15
  • 31