thể trùng lặp:
Using String Format to show decimal upto 2 places or simple integer
How to set decimal point in 2 decimal places?Cách hiển thị số đến 2 chữ số thập phân trong mvc3, C#?
Tôi có lĩnh vực giá theo quan điểm của tôi. nó có các giá trị sau 2.5 and 44.
Tôi muốn hiển thị giá trị này để 2.50 and 44.00
tôi sử dụng đoạn mã sau
@{decimal prolistprice = decimal.Parse(item.OtherFields["Price"].ToString());}
[email protected](prolistprice, 2, MidpointRounding.AwayFromZero)
trong đó item.OtherFields["price"] is a object
tôi chuyển nó sang chuỗi và sau đó thập phân
nhưng Math.round không hoạt động nó cho thấy 2.5 và chỉ 44 .. bất cứ ai có thể giúp này
Tại sao tiêu đề nói "số nguyên"? –
Bạn có thể theo dõi bài đăng này: http://stackoverflow.com/questions/6951335/using-string-format-to-show-decimal-upto-2-places-or-simple-integer –
http://stackoverflow.com/questions/5428289/mvc3-decimal-truncated-to-2-decimal-places-on-edit – alexsuslin