Bug 4620 - Convert.ToDouble() crash on Device and don't on Emulator
Summary: Convert.ToDouble() crash on Device and don't on Emulator
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.3.x
Hardware: Other Other
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-04-24 07:49 UTC by Amine
Modified: 2012-04-25 11:09 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Amine 2012-04-24 07:49:46 UTC
Try Convert.ToDouble("0.0") on Emulator then on Device, you will see a crash.
Comment 1 Sebastien Pouliot 2012-04-24 08:33:54 UTC
This works for me. However I've seen similar cases when the device (like one of mine) is set to another culture (e.g. French uses a ',' for decimal separator).

If your strings do not match the culture of your device then you must either use culture-invariant methods or (more common for parsing) set the current culture to the invariant one while parsing.

			var c = Thread.CurrentThread.CurrentCulture;
			try {
				Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
				Convert.ToDouble("0.0");
			}
			finally {
				Thread.CurrentThread.CurrentCulture = c;
			}
Comment 2 Amine 2012-04-25 11:09:47 UTC
The problem occurs because the culture was not the same on my Mac and my IPad.
Thaks