title: C# List of lists (2D matrix)
body: <p>Im trying to implement a 2D array class using List of Lists. Can someone please help me to implement a get function similar to T this[int x, int y] function below to get all the elements in a column given by [int x,:] where x is the column. Returning as an array would be fine.</p>
  
  <pre><code>public class Matrix&lt;T&gt;
  {
      List&lt;List&lt;T&gt;&gt; matrix;
  
      public Matrix()
      {
          matrix = new List&lt;List&lt;T&gt;&gt;();
      }
  
      public void Add(IEnumerable&lt;T&gt; row)
      {
          List&lt;T&gt; newRow = new List&lt;T&gt;(row);
          matrix.Add(newRow);
      }
  
      public T this[int x, int y]
      {
          get { return matrix[y][x]; }
      }
  }
  </code></pre>