I have a game that is tile-based and every tile has a number ID. I have a list of the tiles each played owns and it’s stored inside of a string with a space between each tile number. How do I convert these numbers into an int array? (And in case anyone asks, it has to stay stored inside of a string for various other reasons).
Thanks, but it was actually an Array. Basically I have this game reading a .txt and on a certain line there are the numbers needed to assign. The solution ended up being:
Where int[ ] represents the array I needed to convert them into and countryFileText represents array of strings (that are equal to the lines of the text file -1)
In short, if anyone else occurs this problem, this is your solution:
int[ ] newIntArray = Array.ConvertAll (theStringYouNeededToDivide.Split (’ '), int.Parse);