title: Splitting a 2D array into 4 smaller 2D arrays
body: <p>I need to loop through a 2D array of ints that is 4x4, but I also have to create 4 2x2 arrays out of it. Then I have to loop through each of those 4 2x2 arrays to pick out the average of the numbers in each 2x2 array. </p>
  
  <pre><code>    public int[,] Reduced(Sampler sampler)
      {
          int[,] a = new int[SampleSize,SampleSize];
  
          for (int r = 0; r &lt; Math.Sqrt(image.Length); r+=SampleSize)
          {
              for (int c = 0; c &lt; Math.Sqrt(image.Length); c+=SampleSize)
              {
                  InsideLoop(a, r, c);                                   
              }
          }
          return a;
      }
  
      private void InsideLoop(int[,] a, int r, int c)
      {
          for (r = 0; r &lt; SampleSize; r++)
          {
              for (c = 0; c &lt; SampleSize; c++)
              {
                  a[r, c] = image[r, c];
                  Console.WriteLine("Value: {0}", a[r, c]);
              }
          }
      }
  </code></pre>
  
  <p>This is essentially what I've got so far, but it's working how it's written instead of how I'd like it to work. For this example, SampleSize is a variable that is set to 2. What this does currently is print out the numbers that create the first 2x2 array four times. My laptop battery is about to die, so I can't elborate more, but if anyone has any tips while I'm driving home. I had to finish posting this on my phone. </p>