.net - Lambda Expression to get the cells vertically for a section containing rows -


i have iterate through each section , create cells rows create table. here each section has rows 0....n, , rows have cells 0...n

for example illustrated below:

row 0->   cell0 | cell1| cell2 | cell3 | cell4 | cell5          row 1->   cell0 | cell1| cell2 | cell3 | cell4 | cell5       row 2->   cell0 | cell1| cell2 | cell3 | cell4 | cell5      .. 

i want create lambda expression (say):

var allcolumns = ...........          

to cell0's cell1's, cell2's etc... can iterate in loop , create table each. requirement not want me go row row wants me go column column (cell illustrated above in diagram, create the cell0's first cell1's cell 2's etc, in loop below.

foreach(cell c in allcolumns){     //i want iterate in loop , create cells , rows.     } 

can give me lambda expression this.

i tried doing

var allcolumns = sections.rows.selectmany(a=>a.cells).groupby(what should come here).                              

can improve or suggest better lambda expression keeping above foreach loop , illustration above in mind. in advance.

you can try demo had put , see if works (it should put in windows console application):

        datatable dt = new datatable();         dt.columns.addrange(new datacolumn[] {                 new datacolumn("col1"),                 new datacolumn("col2"),                 new datacolumn("col3") });          dt.rows.add("cell0", "cell1", "cell2");         dt.rows.add("cell0", "cell1", "cell2");         dt.rows.add("cell0", "cell1", "cell2");         dt.rows.add("cell0", "cell1", "cell2");          // writes out original data         foreach (datarow row in dt.rows)         {             foreach (var column in row.itemarray)                 console.write("{0} ", column);              console.writeline();         }         console.writeline();          // reverses columns , rows         var result = dt.columns                        .cast<datacolumn>()                        .select(column =>                            dt.asenumerable()                             .select(row =>                                 row.itemarray[column.ordinal].tostring()));          // writes out reversed columns , rows         foreach (var row in result)         {             foreach(var column in row)                 console.write("{0} ",column);              console.writeline();         }          console.readkey(); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -