二维数组和嵌套数组的区别
[][]二维数组:数组可以不等长
[,]嵌套数组:数组必须等长
一维数组->二维数组[][]
int[] a = { 1, 2, 3 };
int[] b = { 11, 22, 33,44};
int[][] ab = { a, b };
(参考链接:https://www.cnblogs.com/hitfredrick/p/6403015.html)
一维数组->嵌套数组[,]
(利用Buffer.BlockCopy,参考链接:https://blog.csdn.net/qq826364410/article/details/79729727)
将多个一位数组组成List进行如下变换
static double[,] ToMultidimensionalArray(List<double[]> arrayList)
{
double[,] mdArray = new double[arrayList.Count, arrayList[0].Length];
int rowIndex = 0;
arrayList.ForEach(x =>
{
Buffer.BlockCopy(
x, // src
0, // srcOffset
mdArray, // dst
rowIndex++ * mdArray.GetLength(1) * sizeof(double), // dstOffset
x.Length * sizeof(double)); // count
});
return mdArray;
}