Expression bodied get / set accessors feature in c# 7.0

前端 未结 3 1537
难免孤独
难免孤独 2020-12-20 13:04

I\'m having this code in a class

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

But the compi

3条回答
  •  青春惊慌失措
    2020-12-20 13:38

    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.

提交回复
热议问题