Inline variable declaration not compiling [How to Solve]

Inline variable declaration not compiling
error CS1525: Invalid expression term ‘string’
error CS1003: Syntax error, ‘,’ expectedIn 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="packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.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.

Similar Posts: