Swap two lists in c# -
this question has answer here:
i have list of list (a matrix, sent via web.api http post matlab).
list<list<decimal>> mylist; the size of matrix nxm, how can swap lists? i.e.
mylist[i][j] --> mylist[j][i] in matlab operation mylist' or in mathematical context (transposing)
mylist^t
you use linq achieve without for loop this:
var swapedlist = mylist .selectmany((l, i) => l.select((d, j) => new { i, j, d })) .groupby(l=>l.j) .select(l=>l.select(ll=>ll.d).tolist()); .tolist(); i hope helpful :)
Comments
Post a Comment