Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Objects Loops and Final Touches Constants

Leo Ngai
Leo Ngai
2,184 Points

It keeps on saying compile error. But I did changed the magic numbers. Help!

It keeps on saying compile error. But I did changed the magic numbers. Help!

CodeChallenge.cs
private const int _midtier = 100000;
private const int _hightier = 150000;
private const string _redColor = "red";
private const string _yellowColor = "yellow";
private const string _greenColor = "green";

const int revenue = 125000;
string status = null;

if (revenue < _midtier)
{
    status = _redColor;
}
else if (revenue < _hightier)
{
    status = _yellowColor;
}
else
{
    status = _greenColor;
}

1 Answer

Steven Parker
Steven Parker
221,295 Points

:point_right: Whenever you get a compile error, use the Preview button.

The preview will show you the actual output from the compiler, which can provide a helpful clue. In this case, it's a bunch of messages saying, "Unexpected symbol `private'"

An access modifier doesn't make sense here, so just remove the "private" from your constants and you should pass the challenge since you did change all the "magic numbers" as required.