C# C# Objects Encapsulation and Arrays Ternary If

Ruaridhi O'Scanlain
Ruaridhi O'Scanlain
4,336 Points

isnt this right, asking if ive included the bool expression but think i have?

isnt this right, asking if ive included the bool expression but think i have?

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

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

1 Answer

Daniel Turato
PRO
Daniel Turato
Java Web Development Techdegree Graduate 30,107 Points

The result of ternary returns a value, so just need to assign red/green to textColor like so:

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