How to make razor view engine to use c# 6.0

后端 未结 4 1220
盖世英雄少女心
盖世英雄少女心 2020-12-09 14:57

Currently my razor view engine throws and error saying \"Please use language version 6 or higher\". That may just be resharper giving me a pointer. But how do i make razor u

4条回答
  •  爱一瞬间的悲伤
    2020-12-09 15:04

    If you are running this from a 4.5.1 project, upgrading to 4.5.2 might fix it.

    Otherwise, it is recommended to install this NuGet package to provide the new functionalities: Microsoft.CodeDom.Providers.DotNetCompilerPlatform

    So doing something like this:

    @Model.Person?.Name

    Might work. If it doesn't, try being explicit like this:

    @(Model.Person?.Name)

提交回复
热议问题