Monday, December 14, 2009

Wacky C#: the ?? operator

The "??" is an operator. Yuck. Ugly syntax. What is in the mind of the designers??
See here for details.

Sure it doesn't encourage readable code. It IS ok to use an if statement for more readable code, or use the good old "?:". I can comprehend 1 question mark, but not multiple.

You decide which is more readable
1. foo ?? bar
2. (foo == null) ? bar : foo
3. (foo != null) ? foo : bar

No comments: