Scott recently discovered one of my favorite syntactic niceties in C# 2.0, the Null Coalescing Operator. This operator allows you to return the left side of the statement if it is not null, otherwise return what is on the right.
In other words, instead of writing code like this:
if (o != null) return o; else return defaultObj;
Or this:
return (o != null)? o : defaultObj;
You can simply write this:
return o ?? defaultObj;
It can be a little disorienting when you first see it, but it definitely leads to cleaner code in my opinion.
Another (related) feature in C# is the nullable type declaration which is available thanks to the Generics support added in CLR 2.0. This effectively allows you to have three values for a boolean value ( on, off or null ) - a trick most DBAs know well.
//declare nullable boolean value bool? yourFlag = null;
You can use this syntax to create This also allows you to create a nullable DateTime or int object.
DateTime? selectedDate = null;
int? i = null;
As Ted Neward explained back in 2004, nothing has fundamentally changed under the hood to enable this syntax.
Under the hood, nothing has changed, believe it or not; this was introduced as part of the support for generics, via the System.Nullable<X> type. Nullable<> is a generic wrapper around any value type, and introduces a boolean property "HasValue", to indicate whether the wrapper actually has a value in it, or is in fact pointing to null. The conversion between int? and Nullable<int> is purely a linguistic one, much in the same way the "conversion" between int and System.Int32 is.
Both are very nice additions to an already elegant language.