Hello,
Welcome to Microsoft Q&A!
The reason for this behavior is the Double.NaN itself. Based on the document- Double.NaN Field, it is mentioned that: The Equality operator considers two NaN values to be unequal to one another. In general, Double operators cannot be used to compare Double.NaN with other Double values. And it is suggested to use the IsNaN method.
Like:
if (double.IsNaN(NumberBox.Value))
{
// Some action codes.
}
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.