It's simple:
public IEnumerable<T> this[int x] { get { return _matrix.Select(row => row[x]); } }
Of course, it is better to check if x
is out of range before the LINQ query.
In any case, given that you are working on a matrix, for clarity, you can switch to a two-dimensional array instead of an array with a serrated contour (so do not doubt the size of the two dimensions).
Instead, if performance is really important to you, keep using jagged arrays that seem a little faster than two-dimensional arrays (like LINK1 , LINK2 ).
source share