简体   繁体   English

设备语言不是英语Monodroid时,Double.Parse(string)无法正常工作

[英]Double.Parse(string) not working correct when device language is not english monodroid

I have this code in my android application: 我的Android应用程序中有以下代码:

double lat = Double.Parse (latCoordinate);

When device language is english every thing is right, but when I select other languages it is not working. 当设备语言是英语时,一切都正确,但是当我选择其他语言时,它就不起作用了。

In some languages it say that char '.' 在某些语言中,它说char'。 is not valid. 无效。 An in some others parser the double string bad.for example parse "-95.22222" tp -9.522222 . 在其他解析器中,双字符串bad。例如,解析“ -95.22222” tp -9.522222。

How can i fix this issue? 我该如何解决这个问题?

您应该像下面这样将cultureInfo设置为en-us:

return d.ToString (new CultureInfo ("en-US"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM