In my 3.5 SP1 windows form application the following lines both fail with a format exception.
Double.Parse(double.NaN.ToString(CultureInfo.InvariantCulture),CultureInfo.InvariantCulture);
Double.Parse(double.NaN.ToString());
What could be going on here?
Update:
The format exception only occurs when when you start the application from within Visual Studio (2010) and have the Common Language Runtime Exception notificaion (Debug->Exceptions…) enabled.
I think the exception is being thrown (and caught) within the .NET Framework itself. If you run the program outside of Visual Studio, you should not notice any problems.
I can reproduce this, but if I check ‘Enable Just My Code (Managed Only)’ in the Debugging options for Visual Studio, I no longer see the exception.