我的视图中有价格字段。它有以下值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 .. 任何人都可以帮助这个