c# - Add Multidimensional Array To List -


i have multidimensional double array number of rows , columns:

var values = new double[rows, columns]; 

i have list of double arrays:

var doublelist = new list<double[]>(); 

now, add each column in multidimensional array list. how do that? wrote illustrate want, not work violation syntax.

for (int = 0; < columns; i++) {     doublelist.add(values[:,i]; } 

you need create new array each column , copy each value it.
either simple for-loop (like other answers show) or linq:

for (int = 0; < columns; i++) {     double[] column = enumerable.range(0, rows)         .select(row => values[row, i]).toarray();     doublelist.add(column); } 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -