title: Initializing a jagged array in c# gives index out of range exception
body: <pre><code>field = new int[input.Width][][];
  
  for (int x = 0; x &lt; input.Width; x++)
  {
         field[x] = new int[input.Height][];
  
         for (int y = 0; y &lt; 3; y++)
         {
             field[x][y] = new int[3];
         }
  }
  </code></pre>
  
  <p>For some reason the above code is giving me out of range exception but the following works fine:</p>
  
  <pre><code>field = new int[input.Width][][];
  
  for (int x = 0; x &lt; input.Width; x++)
  {
         field[x] = new int[input.Height][];
  
  }
  
  for (int y = 0; y &lt; input.Height; y++)
  {
  
         for (int x = 0; x &lt; input.Width; x++)
         {
              field[x][y] = new int[3];                   
  
              field[x][y][0] = random.Next(0, output.Width);
              field[x][y][1] = random.Next(0, output.Height);
              field[x][y][2] = MaskFunctions.DSCALE;
  
          }
   }
  </code></pre>
  
  <p>Can anyone point out what am i doing wrong?</p>
  
  <p>Also: Is there a difference between out of range and out of bound exception?</p>