我的视图中有一个价格字段,它具有以下值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.. 有人能帮忙解决吗?