c# - How does comparison operator works with null int? -


i starting learn nullable types , ran following behavior.

while trying nullable int, see comparison operator gives me unexpected result. example, in code below, output "both , 1 equal". note, not print "null" well.

int? = null; int? b = 1;  if (a < b)     console.writeline("{0} bigger {1}", b, a); else if (a > b)     console.writeline("{0} bigger {1}", a, b); else     console.writeline("both {0} , {1} equal", a, b); 

i hoping non-negative integer greater null, missing here?

according msdn - it's down page in "operators" section:

when perform comparisons nullable types, if value of 1 of nullable types null , other not, comparisons evaluate false except !=

so both a > b , a < b evaluate false since a null...


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -