I need to convert an int to a string that is always 9 digits + 2 commas in length.
1 would become 000,000,001
12345 would become 000,012,345
and so on
I know I can use ToString().PadLeft(...) to add the leading zeros but don't know how to add the commas without using a few if tests. Is there a more efficient way to do this?
Just using:
int myint = 12345;
string formatted = myint.ToString("000,000,000");
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