VS 2015 will not build my project as C # 6.0

In each tag, this is an ASP MVC project in Visual Studio 2015. Code in Razor:

@if (Model.AdditionalContacts?.Count > 0) { }

Received error:

The start distribution operator function is not available in C # 5. Use language version 6 or higher.

I am using VS 2015. Why was this not a default?

Steps taken to correct:

  • Open project Properties
  • Click Build
  • Click Advanced
  • Set Language VersiontoC# 6.0
  • Clean / Restore

The same error occurred. Why?

[Edit]: The code works fine in the CS file directly. I even switched the language to "default" and not to C # 6.0, and it works. It does not work in CSHTML files. Doesn't Razor support this? Or maybe it's related to IIS?

+4
1

# 6.0 MVC5 ( Razor), :

  • - MVC 6
  • CodeDOM .NET Compiler, .
+6

Source: https://habr.com/ru/post/1606982/


All Articles