Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed C# Objects!
You have completed C# Objects!
Preview
This bit of syntactic sugar can reduce simple if / else conditionals to a single line.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
we can actually turn into a single
line using the ternary if operator.
0:00
The ternary if operator is
a bit of syntactic sugar
0:02
that can greatly simplify
if else blocks like this.
0:06
I'll show you how it's used here.
0:10
The way we use this is to replace the if
and else along with their curly braces
0:12
with the question mark and
colon characters like so.
0:17
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up