0
public override string teststr => "test";

This code works fine in Visual studio 2015 and VS2017 but throws the following error in Visual Studio 2013:

; expected

Matt Hogan-Jones
  • 2,981
  • 1
  • 29
  • 35
M.Mahajan
  • 15
  • 4

1 Answers1

2

That's an expression bodied property - they are only supported in C# 6.0 or higher.

VS2013 doesn't support C# 6.0 by default, so it won't be able to compile that code.

This answer discusses how to add support for C# 6.0 to VS2013. But is you're using expression bodied properties you really should learn about them more, and what language versions support them.

The expression bodied syntax is equivalent to:

public override string teststr
{
    get
    {
        return "test";
    }
}

for earlier versions of C#.

Community
  • 1
  • 1
Matt Hogan-Jones
  • 2,981
  • 1
  • 29
  • 35