Peter Richter
Peter Richter

Reputation: 805

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?

Upvotes: 2

Views: 574

Answers (1)

Justin Niessner
Justin Niessner

Reputation: 245509

You may be targeting .NET 4.6 but auto-initializers is a C# 6 feature rather than a feature of the Framework.

Upvotes: 3

Related Questions