最近在做一个B/S国际化项目,在越南部署发现小数点和千分位问题,折腾了一天终于找出问题的解决方案。
问题:
页面输入 40.7 convert.todouble("40.7")类型转换后变成40700
页面输入40,7 convert.todouble("40,7")类型转换后变成40.7
解决方案:
CODE
// Gets a NumberFormatInfo associated with the en-US culture.
NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;//国际化数值
NumberFormatInfo nfi1 = new CultureInfo("en-US", true).NumberFormat;//本地化数值
// Displays a value with the default separator (".").
Double myInt = Convert.ToDouble("0.1234", nfi1);//0,1234
Response.Write("本地数值(储存数据库):" + myInt.ToString());
Response.Write("国际化数值(读取数据库后