J
John Salerno
I might decide to use a 3D array, but for now I'm experimenting with 2D.
Here's what I have so far:
for (int x = 0; x < 10; x++)
{
for (int y = 0; y < 10; y++)
{
panelOne[x, y] = switches;
}
}
What I'm trying to do is fill up the panelOne array with values read
from a file and stored in the switches array. (I don't read them
straight into the panelOne array because the switches array is in a
while loop and it's being reused to read each line from the file. Before
the next line is read, the switches array elements are stored
permanently in the panelOne array. Maybe there's a better way?)
Anyway, what I want to know is, how do keep incrementing the indexes so
that it fills up correctly? In the code above, I know it will put the
value of switches[0] in all elements of the panelOne array, because I'm
not incrementing i, but how do I do this? Do I use another for loop, and
if so where do I put it? The above code does
panelOne[0, 0] = switches[0]
and then it does panelOne[0, 1] = switches[0]
How can I make it read panelOne[0, 1] = switches[1]? And then next would
be panelOne[0, 2] = switches[1], and so forth.
The answer might be really easy, but it seems to me that wherever I
increment the i, it's going to mess up incrementing the other variables.
Thanks.
Here's what I have so far:
for (int x = 0; x < 10; x++)
{
for (int y = 0; y < 10; y++)
{
panelOne[x, y] = switches;
}
}
What I'm trying to do is fill up the panelOne array with values read
from a file and stored in the switches array. (I don't read them
straight into the panelOne array because the switches array is in a
while loop and it's being reused to read each line from the file. Before
the next line is read, the switches array elements are stored
permanently in the panelOne array. Maybe there's a better way?)
Anyway, what I want to know is, how do keep incrementing the indexes so
that it fills up correctly? In the code above, I know it will put the
value of switches[0] in all elements of the panelOne array, because I'm
not incrementing i, but how do I do this? Do I use another for loop, and
if so where do I put it? The above code does
panelOne[0, 0] = switches[0]
and then it does panelOne[0, 1] = switches[0]
How can I make it read panelOne[0, 1] = switches[1]? And then next would
be panelOne[0, 2] = switches[1], and so forth.
The answer might be really easy, but it seems to me that wherever I
increment the i, it's going to mess up incrementing the other variables.
Thanks.