The best way to to this is to include any logic in the Model for the View, avoid putting code directly in the View when possible.
However:
In MVC5 and below you'll need to enable the use of new .net features within the Views.
Add this Nuget package to your solution if you are using MVC5.
https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/
The nuget package should modify your web.config, but check that the following configuration is in your web.config file (and if it isn't add it in):
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
More information:
https://stackoverflow.com/questions/30832659/string-interpolation-in-a-razor-view
https://blogs.msdn.microsoft.com/webdev/2015/12/07/new-feature-to-enable-c-6-vb-14/