Simply I'm looking for a way in which to return an integer to thousand separated string format without precisions.
I tried different format specifier but all of them get me 2 digit precisions .
For instances I would like
123456 => "123,456" and not "123,456,00"
or
1234567 => "1,234,567"
and not "1,234,567.00"
You can specify a precision of 0 like this when using the standard numeric format of "n":
string text = value.ToString("n0");
Or in composite form:
Console.WriteLine("The number is {0:n0}", value);
try this:
int myNumber = 1234567;
var myString = myNumber.ToString("n0");
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