different results on emulator and windows phone device c#
So i am working on an application that does some calculations. It reads some numbers from a txt, it converts them to double and after it multiplies them it gives the result.
Lets say the txt has the numbers 10.5 and 2
string string1 = "10.5", string2 = "2";
double double1 = Convert.ToDouble(string1), double2=Convert.ToDouble(string2);
double double3=double1*double2;
textbox.text= double3.ToString();
The result I always get on emulator is 21 while on my device i get 210. I tried reinstalling the app from the phone, restarting the phone and the pc and i tried this over 10 times. I still get different results on my phone. What should i do?
PS: i tried double.parse but still the same
On the basis that the phone and emulator are working under different locales, then this SO question answers what is really being asked how-to-convert-string-to-double-with-proper-cultureinfo
Of course you are now going to have to match your text file to the corrected locale.
Also see what-does-cultureinfo-invariantculture-mean
链接地址: http://www.djcxy.com/p/75116.html