How do i change everything behind a certain point in a Jagged array?

Posted by Jack Null on Stack Overflow See other posts from Stack Overflow or by Jack Null
Published on 2010-05-31T23:31:22Z Indexed on 2010/05/31 23:43 UTC
Read the original article Hit count: 102

Filed under:

Say I have a jagged array, and position 2,3 is taken by int 3. Every other spot is filled with int 0. How would I fill all the positions behind 2,3 with a 4?

0 0 0 0 0 0

0 0 0 0

0 0 0 3 0 0

0 0 0 0 0

to this:

4 4 4 4 4 4

4 4 4 4

4 4 4 3 0 0

0 0 0 0 0

Ive tried variations of this:

int a = 2;
int b = 3;

for (int x = 0; x < a; x++)
{
    for (int y = 0; y < board.space[b].Length; y++)
    {
           board.space[x][y] = 4;
    }
}

© Stack Overflow or respective owner

Related posts about c#