int? x = null;
x = x + 1; // Works, but x remains null
I would expect the compiler to attempt to cast x as an int, but apparently it does not.
Edit by 280Z28: Changed NullReferenceException to InvalidOperationException, which is what Nullable<T>.Value throws when HasValue is false.
This is per the specification for lifted binary operators. From §7.2.7:
The reasoning is this: you are to think of
nullfor a nullable type as meaning "I do not know what the value is." What is the result of "I don’t know" plus one? "I don’t know." Thus, the result should benull.