Today I faced a funny and unexpected thing. What do you think is the result of this:
No, it`s not 7, as I expected, but x == null! So just be careful when working with nullable types!
And just as another reminder:
Probably this behavior comes from the SQL and its three-valued logic (here is a great article about it SQL and the Snare of Three-Valued Logic).
int? x, y, z; z = 7; x = y + z;
No, it`s not 7, as I expected, but x == null! So just be careful when working with nullable types!
And just as another reminder:
default(int?) == null; default(int) == 0;
Probably this behavior comes from the SQL and its three-valued logic (here is a great article about it SQL and the Snare of Three-Valued Logic).
No comments:
Post a Comment