var amount="0";
@String.Format("{0:0.00}", amount)
returns "0"
While I was expecting it to return
"0.00"
var amount="0";
@String.Format("{0:0.00}", amount)
returns "0"
While I was expecting it to return
"0.00"
Formatting a string will just return the string itself, you have to format a number to get it formatted as a number:
var amount = 0;
A variable with implicit type which is assigned an integer value will be an integer, so it won't have a fractional part. You might want to specify the type:
double amount = 0;
Or use a double value:
var amount = 0.0;