Click here to Skip to main content
11,721,289 members (87,477 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hello Codeproject,

I am trying to paste nine multi-dimensional arrays to one big multi-dimensional array.
Basically the smaller ones are 20 by 20, and the bigger one is 60 by 60. So there should fit nine smaller ones in right ? Well apparently I am making it go out of bounds.

Here is the code;

// -- Fill up the Sticked Chunk.
for (int i = 1; i <= 3; i++)
{
    for (int j = 1; j <= 3; j++)
    {
        // -- Right Chunk.
        int RightChunk = i * j;
 
        // -- Get writing cooardinate.
        int WritingX = (i * World.ChunkSize);
        int WritingY = (j * World.ChunkSize);
 
        // -- Get all the Blocks.
        for (int x = 0; x < World.ChunkSize; x++)
        {
            for (int y = 0; y < World.ChunkSize; y++)
            {
                    Block _Block = new Block();
                    _Block.BlockID = LoadedChunks[RightChunk].GetBlockID(x, y);
                    StickedChunk._Blocks[WritingX + x, WritingY + y] = _Block;
            }
        }
    }
}

The 'Sticked Chunk' is the bigger one.

Edit: Anyone ?
Posted 30-Dec-12 8:51am
Yvar Birx2.4K
Edited 30-Dec-12 9:58am
v2
Comments
Sergey Alexandrovich Kryukov at 30-Dec-12 21:09pm
   
What do you mean by "Paste"? Where is the declaration of arrays?
A hint: say, a 2-dimensional array could be int[][] or, a very different thing, int[,].
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Arrays indexes start at 0

Try this instead
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
  Permalink  
v2
Comments
Yvar Birx at 30-Dec-12 16:10pm
   
Thanks, any idea on how to get the numbers 0-8 then ?
Because I need to Write the arrays. >.>
Yvar Birx at 30-Dec-12 16:11pm
   
Edit: Fixed, thanks so much ! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 515
1 OriginalGriff 279
2 Mika Wendelius 170
3 F-ES Sitecore 150
4 cyycoish 70
0 Sergey Alexandrovich Kryukov 2,209
1 OriginalGriff 969
2 F-ES Sitecore 660
3 Maciej Los 609
4 Richard MacCutchan 560


Advertise | Privacy | Mobile
Web04 | 2.8.150901.1 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100