Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Encapsulation with Properties Property Practice

Why am I getting error CS1519?

I tried compiling the code in the Property Practice exercise and I received the Invader.cs(15,22): error CS1519: Unexpected symbol `=>' in class, struct, or interface member declaration error. I even tried adding parenthesis but to no avail.

namespace TreehouseDefense { class Invader { private readonly Path _path; private int _pathStep = 0;

public MapLocation Location => _path.GetLocationAt(_pathStep);

public int Health {get; private set; } = 2;

public bool HasScored {get {return _pathStep >= _path.Length; } }
public bool IsNeutralized => (Health <= 0);

public IsActive => !(IsNeutralized || HasScored);

public Invader(Path path) //Constructor
{
  _path = path;

}

public void Move() => _pathStep += 1;

public void DecreaseHealth(int factor)
{
  Health -= factor;
}

} }

1 Answer

Insert bool before IsActive

public IsActive => !(IsNeutralized || HasScored);

so you have this:

public bool IsActive => !(IsNeutralized || HasScored);