Day to day good stuff I find regarding my work

Wednesday, September 19, 2007

Coalesce



Coalesce goes C# « Only Talking Sense

... the null-coalescing operator in C# 2.0.

string name = (userName == null? “” : userName);



There’s nothing wrong with this code ....but the ternary operator ?
you can now write



string name = userName ?? “
”;



Powered by ScribeFire.

No comments: