C#: double[][] and double[,]

c#, multidimensional-array

Solution

`double[][]` and `double[,]` have different meanings.

`double[][]` is jagged, so some elements can be of different lengths than others.

`double[,]` is "rectangular", so all elements are of the same length.

You could write a method to "convert" between the two, but how will you rectify the differences? I.e. how will you decide to "trim" from the long elements or expand the short elements in order to make it rectangular?

Problem

I confuse between double[][] and double[,] in C#. My teammate give me a function like this: ``` public double[][] Do_Something(double[][] A) { ....... } ``` I want to use this function: ``` double[,] data = survey.GetSurveyData(); //Get data double[,] inrma = Do_Something(data); ``` It lead an error: invalid argument. I don't want to edit my teammate's code. Does it have any way to convert `double[][]` to `double [,]` ? Thanks!

Original source

Related problems