功能“内插字符串"在 C# 5 中不可用.请使用语言版本 6 或更高版本. [英] Feature 'interpolated strings' is not available in C# 5. Please use language version 6 or greater.

查看:33
本文介绍了功能“内插字符串"在 C# 5 中不可用.请使用语言版本 6 或更高版本.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我放入 Razor 视图时,以下行无法编译.

The following line does not compile when I put in a Razor View.

var extPropLookupNameCompania = $"extension_{SettingsHelper.ClientId.Replace("-", "")}_{"Compania"}";

但是在控制器中,同一条线工作得很好.

However in the controller the same line works perfectly fine.

为什么我不能在剃刀视图上使用字符串插值?或者也许我需要配置一些东西?

Why I cant user string interpolation on the razor views? or Maybe I need to configure something?

推荐答案

如果您在 .NET Framework 4.5.1 项目中遇到此错误,升级到 4.5.2 即可解决问题.

If you are experiencing this error in a .NET Framework 4.5.1 project, upgrading to 4.5.2 solves the problem.

这篇关于功能“内插字符串"在 C# 5 中不可用.请使用语言版本 6 或更高版本.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆