c# - ToString ("N2") 和 ToString ("0.00") 之间的区别

ToString("N2")ToString("0.00")有什么区别?

最佳答案

来自 Standard Numeric Format Strings

The number is converted to a string of the form "-d,ddd,ddd.ddd…", where '-' indicates a negative number symbol if required, 'd' indicates a digit (0-9), ',' indicates a thousand separator between number groups, and '.' indicates a decimal point symbol.

似乎 N 将包含千位分隔符,而 0.00 不会。

另见 Custom Numeric Format Strings

https://stackoverflow.com/questions/4506323/

相关文章:

.net - 如何使用缩写的时区显示 DateTime?

php - $SimpleXML->asXML() 的格式输出;

c# - 如何停止 ReSharper 删除对象初始化程序中的空格

ios - 如何将 Double 格式化为货币 - Swift 3

php - 在 PHP 中获取货币符号

c# - 十六进制的 String.Format

c++ - 使用printf打印 float 时有额外的前导零?

c# - 在 C# (asp.net MVC3) 中用逗号和小数格式化数字

python - 如何右对齐数字数据?

ruby - CSV.read 第 x 行的非法引用