Format number with comma separator for thousands using C# [duplicate]
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.
精彩评论