我想將模型中的數字加在一起,并以美元金額的格式顯示它們。
這是我試圖格式化的代碼:
<td class="confirmationlabel">$@(Model.Amount Model.FeeAmount) </td>
如何將輸出格式化為 $0.00 格式?我嘗試將 tostring 添加到末尾,但它無法識別。現在,如果它是一整美元,它會在末尾沒有 .00。
uj5u.com熱心網友回復:
有很多括號要正確設定。
下面的格式應該可以做到。
要么打電話ToString
$@((Model.Amount Model.FeeAmount).ToString("0.00"))
或使用string interpolation(由$下面的第二個表示)
$@($"{(Model.Amount Model.FeeAmount):0.00}")
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/459883.html
標籤:asp.net-mvc
