将多维数组复制到更大的多维数组中! [英] Copying an multi dimensional array to a bigger multidimensional array out of bound !
本文介绍了将多维数组复制到更大的多维数组中!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello Codeproject,
我试图将9个多维数组粘贴到一个大的多维数组中。
基本上是较小的是20乘20,而较大的是60乘60.那么右边应该有九个较小的那个?显然,我正在使它超出界限。
这是代码;
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;
}
}
}
}
'' Sticked Chunk''是更大的一个。
编辑:任何人?
The ''Sticked Chunk'' is the bigger one.
Anyone ?
推荐答案
数组索引从0
请尝试使用
Arrays indexes start at 0
Try this instead
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
这篇关于将多维数组复制到更大的多维数组中!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文