Reputation: 4372
Here is a string format which formats a number up to 2 decimal places and if there are no decimal places then it will show the simple integer itself:
String.Format("{0:0.##}", 123.4567); // "123.46"
String.Format("{0:0.##}", 123.0); // "123"
so {0:0.##}
will do the job. But I need to have a thousand separator on integer part. so something like 1234.456
should be like 1,234.45
. I know {0:n0}
will do a thousand separators but how to combine it with the decimal place formatter?
Upvotes: 0
Views: 2587