Learning by example - terminology (?, :, etc)
c#, operators, terminology, ternary-operator
Solution
`?:` is the conditional operator, and the best way to find out is to ask here!
condition ? first_expression : second_expression;
If condition is true, first expression is evaluated and becomes the result; if false, the second expression is evaluated and becomes the result. Only one of two expressions is ever evaluated.
It's extremely helpful for readability of assignments, when the entire expression is relatively short:
string name = string.IsNullOrEmpty(user.Nickname) ? user.Fullname : user.Nickname
Is much easier and faster than:
string name = user.Fullname;
if(!string.IsNullOrEmpty(user.Nickname))
{
name = user.Nickname;
}
Problem
When you were a kid, did you ever ask your parents how to spell something and they told you to go look it up? My first impression was always, "well if could look it up I wouldnt need help spelling it". (yeah yeah I know phonetics) ...anyway, I was just looking at some code and I found an example like: ``` txtbx.CharacterCasing = (checkbox.Checked) ? CharacterCasing.Upper : CharacterCasing.Normal; ``` I can figure out what this operation does, but obviously, I cant google for ? or : and I cant find them when searching for "c# operators", LINQ, Lambda expressions, etc. So I have to ask this silly question so I can go start reading about it. What are these operators?