我想一些帮助创建以下convertions:
I would like some help to create the following convertions:
一个需要转换的800 * 600多维数组交错数组,然后以相反的同样的方法(锯齿形阵列使用相同的数据到原来的多维数组)
A need to convert an 800*600 multidimensional array into a jagged array and then the same method in reverse (jagged array with the same data to the original multidimensional array)
这可能吗?任何关于它的帮助?
Is this possible? and any help about it?
我知道这个问题是有点老,但针对的flexability的缘故,我modfied方法的位计算方法中的数组的大小,而不是必须通过他们:
I realize the question is a bit old but for flexability sake, I modfied the method a bit to calculate the array sizes within the method as opposed to having to pass them in:
static object[][] convertToJaggedArray(object[,] multiArray)
{
int firstElement = multiArray.GetLength(0);
int secondElement = multiArray.GetLength(1);
object[][] jaggedArray = new object[firstElement][];
for (int c = 0; c < firstElement; c++)
{
jaggedArray[c] = new object[secondElement];
for (int r = 0; r < secondElement; r++)
{
jaggedArray[c][r] = multiArray[c + 1, r + 1];
}
}
return jaggedArray;
}