I done a test and i really do not know the reason why a jagged array who
has the same number of elements as a multidimensional array is faster
here is my test. I assign a value and do a small calculation. Even if i
initialise the jagged array inside the function it is still much faster.
Are these results correct?. If i put the initialisation loop in the
constructor its ridiculously faster but even here its 4 times
faster...is this correct?
private int[,] multi= new int[2000, 2000];
private int[][] jagged = new int[2000][];
private void btnArrayPerformance_Click(object sender, System.EventArgs
e)
{
for(int x = 0;x < 2000;x++)
{
jagged[x] = new int[2000];
}
for(i = 0;i < 2000;i++)
for(j = 0;j < 2000;j++)
{
jagged[j][k] = 8;
jagged[j][k] = (8 * 2);
}
}
private void btnMulti_Click(object sender, System.EventArgs e)
{
for(i = 0;i < 2000;i++)
for(j = 0;j < 2000;j++)
{
multi[j,k] = 8;
multi[j,k] = (8 * 2);
}
}
*** Sent via Developersdex http://www.developersdex.com ***