C# C# Objects Encapsulation and Arrays Ternary If

Quan Nguyen
Quan Nguyen
2,250 Points

I got this Bummer in the Code Challange: "Did you include the boolean expression to evaluate?"

Im not sure what is wrong with my Code.

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

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

1 Answer

That's not how the ternary operator works, it returns a value and you need to assign that returned value to your variable.

Try this `textColor = value < 0 ? "red" : "green";, that should work.

Quan Nguyen
Quan Nguyen
2,250 Points

Yeah I figured, thank you so much!