开发者

Format number with comma separator for thousands using C# [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

String.Format an integer to use 1000's separator without decimal places or leading 0 for small 开发者_开发问答integers

The blog post

http://blog.stevex.net/string-formatting-in-csharp/

(in the Custom number formatting section) shows that using the format {0:0,0}, a number like 1500 will be formatted as 1,500 which is good. But I don't understand why 0 is formatted as 00

Do I need to handle the case of 0 separately which doesn't seem to be necessary.


You can use "F0", which is "fixed number with 0 decimal places". It give you a thousands separator when you results go over 1,000.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜