Inline variable declaration not compiling

Inline variable declaration not compiling

 error CS1525: Invalid expression term 'string'
error CS1003: Syntax error, ',' expected

In case the above answer doesn't work for you, as it didn't work for me do the following:

Open the csproj file and check if you have the following package referenced in the file after the upgrade, if yes, remove it.

<Import Project="packagesMicrosoft.Net.Compilers.1.3.2uildMicrosoft.Net.Compilers.props" Condition="Exists('packagesMicrosoft.Net.Compilers.1.3.2uildMicrosoft.Net.Compilers.props')" />

Next, check the "Project ToolsVersion". It has to be 15.0, it probably is 14.0 though so you have to change that.

<Project ToolsVersion="15.0" .../>

Then simply reload the SOLUTION and you're good to go. Be aware that if you select "Reload Project" it will give you an error and not load it. 

原文地址:https://www.cnblogs.com/chucklu/p/15194093.html