Reputation: 10330
I read a lot of articles about number format string, ex: http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
I really not understand how to write the best format string. To get a excepted result, I can write some ways. Example: print number 1234567890 as a text "1,234,567,890". These ways give the same result:
1234567890.ToString("#,#")
1234567890.ToString("#,##")
"#,##" is the popular one on internet but why? Please give me some information how to write a good format string. Thanks.
Upvotes: 6
Views: 169
Reputation: 20076
As far as I can see, there is no difference between "#,#"
and "#,##"
: both mean 'format a number with group separators and without the fractional part'. Refer to SSCLI source for general number formatting for the gory details.
Upvotes: 1
Reputation: 19828
In your case it does not matter, because you are using int
. This format #,##
and #,#
are for doubles and means that print only two digits after decimal point
Upvotes: 0