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 Encapsulation and Arrays Ternary If

Jory Braun
Jory Braun
7,814 Points

Uh this is dumb, error: Did you include the boolean expression to evaluate? (value < 0) ?

(value < 0) ? textColor = "red" : textColor = "green";

CodeChallenge.cs
int value = -1;
string textColor = null;

(value < 0) ? textColor = "red" : textColor = "green";

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,865 Points

Hi Jory,

I haven't taken this C# course, but usually I write the C# ternary this way.

textColor = (value < 0) ? "red" : "green";

Hope you find it helpful.

Jory Braun
Jory Braun
7,814 Points

that is far sexier

Jory Braun
Jory Braun
7,814 Points

but the question is very vague, I don't know why this wouldn't pass. This is my biggest complaint about treehosue. You get an error some times for no rhyme or particular reason.

Charles Parko
Charles Parko
2,012 Points

I don't have an answer, but will add, that I have no idea why your code (which is identical to mine) didn't pass. I did exactly what the instructor shows in the video. It would be really nice if after awhile, we got an explanation around what's wrong.