c# - String.Format decimal with both thousand separators and forced decimal places -


i'd string.format decimal has both thousand separators , forced decimal places (3).

for example:

input:

123456,12 78545,8 

output:

123.456,120 78.545,800 

i have tried

string.format("{0:0.0,000}", input); 

but gives thousand separators doesn't force decimal places.

in custom numeric format string period (.) used "localized decimal separator". ie. if current locale uses comma decimal separator should use period in format string. comma (,) used localised thousands separator.

as format puts comma after period things going confused (thousands separators don't apply after decimal point).

so try:

 string.format("{0:#,##0.000}", input); 

(using # digits include if input large enough.)


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -