日期:2014-05-19  浏览次数:21059 次

关于小数位数设置问题(货币类型Money)
money类型的小数位数默认为4位,要怎样才能把money类型的小数位数改为两位呢?

------解决方案--------------------
比如:
double aaa=123556.2364;
//this is C2 result:¥123,556.24
Response.Write(string.Format( "this is C2 result:{0:C2} ", aaa)+ " <br> ");
//this is F2 result: 123556.24
Response.Write(string.Format( "this is F2 result:{0,10:F2} ", aaa) + " <br> ");
------解决方案--------------------
C或c
格式化为货币,数字会附加一个货币符号,对数字进行位数分割,并默认设置2个小数位;
string.Format( "{0:C} ", yourMoney)
------解决方案--------------------
NumberFormatInfo nfi = new CultureInfo( "en-US ", false ).NumberFormat;
nfi.NumberDecimalDigits=2
string.ToString( "N ",nfi),