[英]How to format decimal in c# asp-format tag to 2 decimal points and without trailing zeros if it is an int?
How to format decimal in c# asp-format tag to 2 decimal points and without trailing zeros if it is an int?如何将 c# asp-format 标记中的小数格式化为 2 个小数点,如果它是 int,则不带尾随零?
<input asp-for="X" asp-format="{0:0.00}" />
I need:我需要:
123.456 => 123.46
123.45 => 123.45
123.4 => 123.40
123 => 123
thanks谢谢
Try this 尝试这个
asp-format="{0:0.##}" asp-format =“ {0:0。##}”
asp-format is correct. asp格式是正确的。 Change the format syntax.更改格式语法。
asp-format="{0:n2}" asp-format="{0:n2}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.