Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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
GitHub or Developer Community 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.
Windows 8.1. Visual Studio 2015 Update 3.
The result on the Windows .NET 4.6 platform:
// Result = 0.0123
var result2 = decimal.Parse("0,0123");
// There is an exception FormatException.
var result1 = decimal.Parse("0.0123");
The result on the Android Emulator x86:
// Result = 0.0123. The dot is allowed
var result2 = decimal.Parse("0.0123");
// No exceptions. Result = 123
var result1 = decimal.Parse("0,0123");
See example code on github:
It turned out that it was an bug on x86 (which is reproduced on the simulator android). On a real device ARM's all good.
@Sergey, number parsing is dependent on the locale/culture settings on the given machine, device. As such, this behavior is not a bug - the environment you run in may indicate that a dot is a valid decimal separator along with the comma. Yet another environment, even for the same culture, may have different locale/cultural settings that prevent using the dot or the comma in the same situation. In general, when parsing decimals it is advised to first try parsing using the current culture, whatever it is, especially when the input comes from the user and then fall back to the known/possibly valid culture(s). Also, using `TryParse` is advisable.
@Marek, thank you.