Wednesday, July 22, 2009

Coalescing operator in C#: ??

It's been a long time ! But another hopefully handy link about the maybe-not-so-well-known (At least by my I must admit) coalescing operator in C#.

return myObject ?? new MyObject();

basically returns myObject if it's not null. If it is, a new Instance of MyObject is returned..

http://www.sturmnet.org/blog/2005/06/15/doublequestionmark

Handy, no ?