title: matrix to array c#
body: <p>Which would be the most efficient way to convert a squared matrix like</p>
  
  <pre><code>  1 2 3 
    4 5 6
    7 8 9 
  </code></pre>
  
  <p>into</p>
  
  <pre><code>[1 2 3 4 5 6 7 8 9]
  </code></pre>
  
  <p>in c# </p>
  
  <p>I was doing</p>
  
  <pre><code>int[,] array2D = new int[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
  int[] array1D = new int[9];
  int ci=0;
  
   for (int i = 0; i &lt; 3; i++)
   {
        for (int j = 0; j &lt; 3; j++)
        {
              array1D[ci++] = array2D[i, j]);
        }
   }
  </code></pre>