Kijana Woodard

Programming and Perceptual Dissonance


NullOr Extension Method

Wednesday, May 19, 2010

I find myself writing code like this a lot:

I thought about adding an operator like ??? to go with ?? and ?, but you can’t do that in c# and it would probably be confusing to the next programmer anyway.

So how about an extension method to wrap that up:

Not a lot less typing, but a bit clearer and you’re less likely to screw up.