Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm having this code in a class

private string test;
public string Test
{
    get =>  test;
    set => test = value;
}

But the compiler won't let me compile. It says

CS1043 { or ; expected 
CS1513 } expected

I'm using VS 2017 and targeting .NET FW 4.6 with a MVC 5 Project

Any idea why it isn't working?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.8k views
Welcome To Ask or Share your Answers For Others

1 Answer

You have to set the compiler to version 7 in your project.

Project properties → (tab) Build → Advanced → Language version = C# 7.0

UPDATE BY @gsharp

check also your (NuGet) reference to the .NET Compiler platform Microsoft.Net.Compilers.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...