0

I want to add figures together from model and display them formatted like a dollar amount.

Here is the code I'm attempting to format:

<td class="confirmationlabel">$@(Model.Amount + Model.FeeAmount) </td>

How do I go about formatting the output to be in $0.00 format? I tried adding tostring to the end but it didn't recognize it. Right now, if it is a whole dollar, it comes out without the .00 at the end.

1 Answer 1

2

There are quite some parenthesis to get set correctly.
The formats below should do it.

Either call ToString

$@((Model.Amount + Model.FeeAmount).ToString("0.00"))

Or use string interpolation (represented by the second $ here below)

$@($"{(Model.Amount + Model.FeeAmount):0.00}")
Sign up to request clarification or add additional context in comments.

1 Comment

ty should have thought of that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.