I want to display a number with commas and decimal point
CASE1 : example if the number is 3494309432324
display as 34,94,30,94,32,324 but not 34,94,30,94,32,324.00
Case 2 : if the number has decimal values them till 2 decimal points and with commas
display as 12,22,222.32
currently i do this for 2 decimal places but i dont get the commas
Label9.Text = sisRatio.ToString("#0.00");
any suggestions..
thanks
Using Commas in Numbers (US, UK, and China) In the US, UK, and China, a comma is placed every 3 decimal places for numbers larger than 999. The decimal point is shown with a period (full stop).
And in countries where a point is used as a decimal separator, a comma is usually used to separate thousands. So, for example, twelve thousand five hundred with a decimal of five zero is written differently depending on the country: In the USA, Mexico, or the UK, it would be written: 12 500.50 or 12,500.50.
Difference exist, even when the same language is spoken. Canada is particularly tricky: Quebec uses the system in France (no commas for large numbers with commas for small numbers) while the rest of Canada uses the method popular in Australia (no commas for large numbers with decimals for small numbers).
The first digit after the decimal represents the tenths place. The next digit after the decimal represents the hundredths place. The remaining digits continue to fill in the place values until there are no digits left.
Assuming you want the usual 3 numbers then a comma, I think this will do what you need:
Label9.Text = sisRatio.ToString("#,##0.##");
One slight issue with this is that it will only one decimal place if the second one would be 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With