Original Post
Hello everyone.
I have the following file that looks like this:-
now I'm reading it and I stored all the data into 1D string array. Then I parse that 1D string array to 1D Int array. However I need to copy the data to 2D array. I have been trying to do it but I can't seem to get my head around it.
Here is my code
so i want to do something like this
you know store the first row when y = 0; second row when y = 1; etc...
I have the following file that looks like this:-
1,2,3,4,5,6,7,8,9,
10,11,12,13,14,15,
16,17,18,19,20,21,
now I'm reading it and I stored all the data into 1D string array. Then I parse that 1D string array to 1D Int array. However I need to copy the data to 2D array. I have been trying to do it but I can't seem to get my head around it.
Here is my code
class Program
{
static void Main(string[] args)
{
string buffer;
string[] map = new string[100];
int[] mapint = new int[100];
buffer = File.ReadAllText("D:/123.txt");
buffer = buffer.Replace("\r", string.Empty).Replace(" ", string.Empty);
map = buffer.Split(',');
for (int i = 0; i < 20; i++)
{
mapint = Convert.ToInt32(map);
Console.Write(mapint + " ");
}
Console.ReadKey();
}
}
so i want to do something like this
for(int x = 0; x < row; x++)
for(int y = 0; y < column; y++)
map[x, y] = mapint[x];
you know store the first row when y = 0; second row when y = 1; etc...