I need to split a number into even parts for example:
32427237 needs to become 324 272 37
103092501 needs to become 103 092 501
I'm sure I could just for-next the numbers, but I'm sure there is a more efficient way as I don't want to miss the characters in these numbers - the numbers themselves can be any length so if the number were 1234567890 I'd want it split into these parts 123 456 789 0
I've seen examples in other languages like Python etc but I don't understand them well enough to convert them to C# - looping though the characters and then at the third getting the previous and then that index to get the section of the string may do the job, but I'm open to suggestions on how to accomplish this better.
Try this:
This is half a decade late but:
A nice implementation using answers from other StackOverflow questions:
AsChunks(): https://stackoverflow.com/a/22452051/538763
ToCsv(): https://stackoverflow.com/a/45891332/538763
One very simple way to do this (not the most efficient, but then not orders of magnitude slower than the most efficient).
Heres an alternate
I would do something like this, although I'm sure there are other ways. Should perform pretty well.
LINQ rules:
UPDATED: