c# - How to extract one column from a jagged array? -


i have jagged array matrix m rows , n columns (i know have used normal matrix read matrix multiplication faster using jagged array).

i'd extract every row 1 column without using loop. how accomplished. also, please explain code because found answer claims following should work cannot figure out how adapt situation.

object[] column = enumerable.range(0, myarray.getlength(0))                             .select(rownum => (object)myarray[daily.m, daily.n])                             .toarray();  

okay following answer doesn't seem give me errors i'm running problem:

var selectedarray = myarray.where(o => (o != null && o.count() > daily.dependentvarindex)).select(o => o[daily.dependentvarindex]).toarray();             method1 m1 = new method1(13);             (int = 0; < daily.m; i++)             {                 m1.do(selectedarray[i]); //this give me error             } 

how can index object "selectedarray"? note defined method1, fxn "do" earlier in code.

using lambda:

var jaggedarray = new int[5][]; jaggedarray[0] = new[] { 1, 2, 3 }; // 3 item array jaggedarray[1] = new[] { 7, 6 }; jaggedarray[3] = new int[10]; // 10 item array of 0's  const int selectitem = 0; var selectedarray = jaggedarray     .where(o => (o != null && o.count() > selectitem))     .select(o => o[selectitem])     .toarray(); 

following array should contain 3 items

[1, 7, 0]


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -