I am using the format ToString("0,0") to display a number like
5000 as 5,000but if the number is 0 - 9, it displays 01, 02, 03, etc. Does anyone know the correct syntax so it does not display the leading 0?
Thanks, XaiSoft
ToString("#,0")
Also, this may help you further
What you are looking for is the string formatter "N0". Example:
int x = 10000;
int y = 5;
Console.WriteLine(x.ToString("N0"));
Console.WriteLine(y.ToString("N0"));
Prints:
10,000
5
More information here.
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