Per tags this is an ASP MVC project in Visual Studio 2015. Code in Razor:
@if (Model.AdditionalContacts?.Count > 0) { }
Error received:
Feature 'null propagating operator' is not available in C# 5. Please use language version 6 or greater.
I'm using VS 2015. Why was this not defaulted?
Steps taken to fix:
- Open Project's
Properties
- Click
Build
- Click
Advanced
- Set
Language Version
toC# 6.0
- Clean / Rebuild
Same error occurs. Why?
[Edit]: The code works fine in the CS file directly. I even switched the language back to "default" rather than C# 6.0 and it works. It only does not work in the CSHTML files. Does Razor not support this? Or perhaps this is related to IIS?