【发布时间】:2012-10-28 10:12:12
【问题描述】:
可能重复:
Using String Format to show decimal upto 2 places or simple integer
How to set decimal point in 2 decimal places?
我的视图中有价格字段。它具有以下值2.5 and 44.
我想将此值显示给2.50 and 44.00 我使用以下代码
@{decimal prolistprice = decimal.Parse(item.OtherFields["Price"].ToString());}
$@Math.Round(prolistprice, 2, MidpointRounding.AwayFromZero)
其中item.OtherFields["price"] is a object我将其转换为字符串,然后转换为十进制
但 Math.round 不工作它只显示 2.5 和 44.. 任何人都可以帮助这个
【问题讨论】:
-
为什么标题是“整数”?
-
你可以关注这个帖子:stackoverflow.com/questions/6951335/…
标签: c# asp.net asp.net-mvc-3