I am starting to learn types with a null value and encounter the following behavior.
When trying a nullable int, I see the comparison operator gives me an unexpected result. For example, in my code below, the output I get is "and 1 are equal . " Please note that it also does not print "zero".
int? a = null; int? b = 1; if (a < b) Console.WriteLine("{0} is bigger than {1}", b, a); else if (a > b) Console.WriteLine("{0} is bigger than {1}", a, b); else Console.WriteLine("both {0} and {1} are equal", a, b);
I was hoping that any non-negative integer would be greater than zero, did I miss something here?
c # nullable
Ron5504 Apr 3 '13 at 2:14
source share