简体   繁体   中英

Auto-property initializers won't work?

I'm trying to use auto-property initializers , like so:

class Class1
{
    public string Auth { get; set; } = "BlahBlah";
}

However, when I build, I get the following error:

Invalid token '=' in class, struct, or interface member declaration

This is in Visual Studio 2013, using Target Framework .NET 4.6 (which is the version which introduced auto-property initializers).

Is there something wrong with my syntax?

您可能以.NET 4.6为目标,但是自动初始化器是C#6的功能,而不是Framework的功能。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM