title: C# fill 2D array matrix using single for loop
body: <p>I'm currently messing around with 2D arrays. I want to Fill a 2D array with a count. I've managed to do this using 2 nested for loops. (That's probably the easiest way of doing it right?)</p>
  
  <pre><code>//create count
  int count = 1;
  
  for (int row = 0; row &lt; matrix.GetLength(0); row++)
  {
      for (int col = 0; col &lt; matrix.GetLength(0); col++)
      {
          matrix[row, col] = count++;
      }
  }
  </code></pre>
  
  <p>I was just curious, is it also possible to fill this 2D array using only a single for loop?</p>
  
  <p>I thought of making a loop that counts the rows. When the rows reaches the end of the array the column wil be increased by 1. This could probably be done by using some if, if else and else statements right?</p>
  
  <p>Does someone here have any idea how to make this work?</p>