I know I can format strings using the String.Format() method. Is it possible to format like this?
Example:
string: 1568
formatted: 1.568string: 168794521
formatted: 168.794.521string: 987
formatted: 987
Sorry that I can't make myself more clear.
You can format a number that way, but not a string. For example, if you have an integer value, you can use:
int value = 168794521;
string formatted = value.ToString("N0");
With the proper culture, this will format as shown.
If you are using a string, you would need to convert it. You could also explicitly provide a culture to guarantee "." as a thousands separator:
int value = Int32.Parse("168794521");
string formatted = value.ToString("N0", new CultureInfo("de-DE"));
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