使用Double.IsNaN()方法来判断数值计算结果是否是非数字。
if (Double.IsNaN(0 / zero))
{
Console.WriteLine("Double.IsNan() can determine whether a value is not-a-number.");
}
else
{
//todo
}
if (Double.IsNaN(0 / zero))
{
Console.WriteLine("Double.IsNan() can determine whether a value is not-a-number.");
}
else
{
//todo
}