title: Array operations with n-dimensional array using LINQ (C#)
body: <p>Assume we have a jagged array</p>
  
  <pre><code>int[][] a = { new[] { 1, 2, 3, 4 }, new[] { 5, 6, 7, 8 }, new[] { 9, 10, 11, 12 } };
  </code></pre>
  
  <p>To get a sum of second row and sum of second column, it can be written both code lines respectively:</p>
  
  <pre><code>int rowSum = a[1].Sum();
  int colSum = a.Select(row =&gt; row[1]).Sum();
  </code></pre>
  
  <p>But if we have definition of 2-dimensional array</p>
  
  <pre><code>int[,] a = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } };
  </code></pre>
  
  <p>the above-cited code will not work due to compiller errors:</p>
  
  <pre><code>Error   1   Wrong number of indices inside []; expected 2
  Error   2   'int[*,*]' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'int[*,*]' could be found (are you missing a using directive or an assembly reference?)
  </code></pre>
  
  <p>So, the question: How to use LINQ methods with n-dimensional arrays, but not jagged ones? And is where a method to convert rectangular array to jagged?</p>
  
  <p>P.S. I tried to find the answer in documentation, but without result.</p>