How to optimize this nested for loop where the most overhead is from the multi dimensional array index lookup
<p>for example</p>

<pre><code> for (int i=0;i&lt;100;i++)
   for (int j=0;j&lt;100;j++)
     for (int k=0;k&lt;100;k++)
       for (int l=0;l&lt;100;l++)
         for (int m=0;m&lt;100;m++)
  {
     DoSth(myArray[i,j,k,l,m]);
  }
</code></pre>

<p>I tried to convert 5dimensional myArray into int[][][][][] myJaggedArray, it is still slow.</p>

<p>Is there any way I can improve it?
Note:  the most overhead comes from the multi dimensional array index lookup</p>

<p>There is one ugly way i can think of:  (e.g. 2 nested loop)</p>

<pre><code>for (int i=0;i&lt;100;i++)
 {
   var tmp = myJaggedArray[i];
   {
     for (int j=0;j&lt;100;j++)
     {
      DoSth(tmp[j]);
      }
   }
 }
</code></pre>
