I have lines (string type) of numbers like "23 78 53 4 94 32 148 31". I need to put them into int array. Here's the lame code I wrote, but it doesn't work properly:
int currentArrayValue=0;
int currentChar=0;
for (int i = 0; i < text1.Length; i++)
{
if (text1[i] != ' ')
{
currentChar++;
continue;
}
else
{
for (int k = 1; k <=currentChar; k++)
{
if (k == 1) Array[currentArrayValue] = text1[i - currentChar];
else if (k == 2) Array[currentArrayValue] = text1[i - currentChar] * 10;
else if (k == 3) Array[currentArrayValue] = text1[i - currentChar] * 100;
}
currentArrayValue++;
}
}
It can be a one-, two- or three-digit number.