Getting a double[] row array of a double[,] rectangular array

后端 未结 6 1816
夕颜
夕颜 2021-02-13 13:43

Suppose you have an array like:

double[,] rectArray = new double[10,3];

Now you want the fouth row as a double[] array of 3 elements without do

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-13 14:37

    You probably want to use a jagged array. That is not an array of 10 by 3 but instead an array of arrays.

    Something like :

            double[][] rectArray;
             ....
            double [] rowArray = rectArray[3];
    

    There are lots of places to learn more about jagged arrays. For example Dynamically created jagged rectangular array

提交回复
热议问题