转换字符串到数字类型
作者:互联网
问题:在本地转换数字没有问题但是发布到服务器报数据类型转换失败的信息.
答案:本地的语言版本和服务器语言版本不一样。
在web.config 中添加如下信息即可.
<system.web>
<globalization culture="en-us" />
</system.web>
--转--
Link:
http://stackoverflow.com/questions/5275380/input-string-was-not-in-a-correct-format-2?answertab=active#tab-top
As far as I know the Convert
methods use the current locale to do such conversions. In this case I'd guess your current locale would expect a comma as decimal point. Try to set the current locale for your application or the conversion to some language/country where dots are used (e.g. en_US). The method should provide a second optional parameter to provide a IFormatProvider as an alternative solution.
简体中文(中国)
zh-cn
繁体中文(台湾地区)
zh-tw
繁体中文(香港)
zh-hk
英语(香港)
en-hk
英语(美国)
en-us
英语(英国)
en-gb
转载于:https://www.cnblogs.com/konglingxing/p/5150513.html
标签:en,zh,数字,locale,current,繁体中文,字符串,转换,com 来源: https://blog.csdn.net/weixin_30879169/article/details/98770163