How to get a dimension (slice) from a multidimensional array

前端 未结 4 906
时光取名叫无心
时光取名叫无心 2020-12-01 12:16

I\'m trying to figure out how to get a single dimension from a multidimensional array (for the sake of argument, let\'s say it\'s 2D), I have a multidimensional array:

4条回答
  •  一生所求
    2020-12-01 12:28

    This should replicate the a[r] functionality of a jagged array:

    T[] Slice(T[,] a, int r) => Enumerable.Range(0, a.GetUpperBound(1) + 1).Select(i => a[r, i]).ToArray();
    

提交回复
热议问题