double.IsNaN()
to check if a double
is NaN
CS-W1003By specification, NaN
is not equal to anything, not even itself. Therefore, comparing any double
with NaN
will always evaluate to false
. The preferred and right approach is to directly use the double's .isNaN
method.
var d = double.NaN;
d == Double.NaN; // evaluates to false
var d = double.NaN;
double.IsNaN(d); // evaluates to true