We have the following object
int [,] oGridCells;
which is only used with a fixed first index
int iIndex = 5;
for (int iLoop = 0; iLoop < iUpperBound; iLoop++)
{
//Get the value from the 2D array
iValue = oGridCells[iIndex, iLoop];
//Do something with iValue
}
Is there a way in .NET to convert the values at a fixed first index into a single dimension array (other than by looping the values)?
I doubt it would speed up the code (and it may well make it slower) if the array is only being looped once. But if the array was being heavily manipulated then a single dimension array would be more efficient than a multi dimension array.
My main reason for asking the question is to see if it can be done and how, rather than using it for production code.