float.NaN in C#

Hi

I have an instance variable of type float that I set to float.NaN if the relevant column in the database is null. When I iterate through an arraylist containing these objects, I want to check the float value.

eg.

for (int j=0; j<arraylist.Count; j++)
{
Order order = (Order) arraylist[j];

if (order.amount != float.NaN)
{
Console.Writeline(amount.ToString());
}
else
{
Console.Writeline();
}
}

But this seems to ignore the else part and it displays NaN when the amount is NaN.

How would I use the float.NaN?

Thanks.

Kobus
[639 byte] By [kobus] at [2007-11-19 12:59:26]
# 1 Re: float.NaN in C#
See documentation for System.Single:

Use IsNaN to determine whether a value is not a number. It is not possible to determine whether a value is not a number by comparing it to another value equal to NaN.

e.g.

if (!Single.IsNaN(order.amount))
{
Console.Writeline(amount.ToString());
}
klintan at 2007-11-9 1:51:40 >