转换字符串到数字类型

 

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

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

 

在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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值