arrays - C# List of lists (2D matrix) -


im trying implement 2d array class using list of lists. can please me implement function similar t this[int x, int y] function below elements in column given [int x,:] x column. returning array fine.

public class matrix<t> {     list<list<t>> matrix;      public matrix()     {         matrix = new list<list<t>>();     }      public void add(ienumerable<t> row)     {         list<t> newrow = new list<t>(row);         matrix.add(newrow);     }      public t this[int x, int y]     {         { return matrix[y][x]; }     } } 

or: return matrix.select(z=>z.elementatordefault(x));


Comments

Popular posts from this blog

Python __call__ special method practical example -

arrays - jQuery - Retrieve values from HTML elements and return their sum -