C# C# Objects Encapsulation and Arrays Ternary If

michael edmondson
michael edmondson
3,369 Points

Did you include the boolean expression to evaluate?

ive tried this a few ways and even looked at some youtube videos how or where do i add the boolean expression

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

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

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 51,734 Points

Steven provided the syntax in your previous post

variable = (test condition) ? (value if true) : (value if false)

Here textColor is the variable, your boolean expression is the test condition, "red" is the value if true, and "green" is the value if false.