Merging multi-dimentional arrays

夙愿已清 提交于 2019-12-12 01:53:24

问题


How would I go about and merge a few multidimentional arrays to one large one, using C#?

How things are set up right now i eventually get one large 2d-array that holds a a few other 2d-arrays, and I need a good way to piece the arrays together.

To explain a bit better i have one array: Object[,] largeArray

and each Object hold another array: Grid[,] smallArray

And I want to create a large grid from the content in the smallArrays, keeping the position they had in the largeArray. So the grid at largeArray[0, 1] would be placed right above largeArray[0, 0] and so on.

Clarification: If the largeArray is:

[[A, B], 
[C, D]] 

where A is:

[[a, a], 
[a, a]]

(And so on) the result I want should then look like this:

[[a, a, b, b], 
[a, a, b, b], 
[c, c, d, d], 
[c, c, d, d]]

The resulting Grid[,] will have the exact same size as all the small ones combined. I know that i could loop through every single element and add them individually, but is there a better way? Seeing as they already are aligned correctly in the smaller grids.

Thanks for any feedback!

来源:https://stackoverflow.com/questions/26952165/merging-multi-dimentional-arrays

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!