首页 > 其他 > 详细

转换字符串到数字类型

时间:2016-01-22 13:37:29      阅读:257      评论:0      收藏:0      [点我收藏+]

 

问题:在本地转换数字没有问题但是发布到服务器报数据类型转换失败的信息.

答案:本地的语言版本和服务器语言版本不一样。

 

在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

转换字符串到数字类型

原文:http://www.cnblogs.com/konglingxing/p/5150513.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!