<分区>
Possible Duplicate:
Using String Format to show decimal upto 2 places or simple integer
How to set decimal point in 2 decimal places?
我的 View 中有价格字段。它具有以下值 2.5 和 44。
我想将此值显示为 2.50 和 44.00
我使用以下代码
@{decimal prolistprice = decimal.Parse(item.OtherFields["Price"].ToString());}
$@Math.Round(prolistprice, 2, MidpointRounding.AwayFromZero)
其中 item.OtherFields["price"] 是一个对象
我将它转换为字符串,然后是小数
但是 Math.round 不工作它只显示 2.5 和 44.. 任何人都可以帮助这个