C# in Depth

Cover of C# in Depth
Order now (3rd edition)

Wording around null comparisons

Chapter 1: The changing face of C# development: P 13, final paragraph

Created: 7/29/2008
Last updated: 7/29/2008
Severity: Language improvement

When introducing nullable values, I say this in the book:

a product with an unknown price will be considered to be less expensive than $10, which is probably what we'd want.

It's not clear that this is because we use the greater-than operator to do the comparison with $10, and that greater than and less than comparisons with null values are always false. So, if instead of price > 10m our comparison had been !(price <= 10m) (a comparison which looks like it will do the same thing) we'd get the wrong answer.

This is fully explained on P125 when discussing nullable types in more depth.