how to divide a string with number at a certain amount?

Hello, my game has a currency, and i am displaying that currency on a UI Text component.
and when the amount get’s to high, the numbers gets to hard to read.

example on what is happening: money: 1241435356 $

example of what i want to achieve: 1 241 435 356 $

i need spaces between “every third” number, to make them less harder to read.

Thanks!

You should be able to use C#'s standard numeric formatting.

See here for details.

Just ask if you need more explanation. I can provide some examples.

In general the ‘number format strings’ with ToString() are the handiest way to format numbers to strings.

To get a space as the “group separator” you have to make your own NumberFormatInfo and specify your own group separator for it instead of the normal ‘,’ as shown here

var nfi = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
nfi.NumberGroupSeparator = " ";
string formatted = 1234897.11m.ToString("#,0.00", nfi); // "1 234 897.11"