With more syntactic sugar making its delicious way into ever increasing C# versions, we get symbol based operators with names escape me. Except my friend and I seem to always remember
??, or the null-coalescing operator. It's a catchy name. ¯\_(ツ)_/¯
This post isn't new and revolutionary. It's a reference post for future me when Google doesn't return the documentation for
?.. The explanations are just going to be linked and lifted from official Microsoft documentation. Here's to you, future me.
The null-coalescing operator
?? returns the value of its left-hand operand if it isn't
null; otherwise, it evaluates the right-hand operand and returns its result. The
?? operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-null.
The null-coalescing assignment operator
??= assigns the value of its right-hand operand to its left-hand operand only if the left-hand operand evaluates to
??= operator doesn't evaluate its right-hand operand if the left-hand operand evaluates to non-null.
The conditional operator
?:, also known as the ternary conditional operator, evaluates a Boolean expression and returns the result of one of the two expressions, depending on whether the Boolean expression evaluates to
Discards are temporary, dummy variables that are intentionally unused in application code.
Bonus Round: LINQ Syntax
You know how LINQ can look like code but can also somewhat look like SQL? They're called Method Syntax and Query Syntax respectively. Docs found here. Though I also find the Method Syntax is often called Fluent Syntax too.