How can I convert 2D array to 1D array

  • Thread starter Thread starter Tonyukuk
  • Start date Start date
T

Tonyukuk

For example I have an 2D array.
int [,] array=new int[2,2];
and I can convert it into one[4]
how can I do that ?
 
Every 2D array is in fact a one D array...
The rows are behind each other.
So you have to split it up.

Tonyukuk said:
For example I have an 2D array.
int [,] array=new int[2,2];
and I can convert it into one[4]
how can I do that ?
 
Hello:
For example I have an 2D array.
int [,] array=new int[2,2];
and I can convert it into one[4]
how can I do that ?

Try using Buffer.BlockCopy
 
Hi,

To convert 2D to 1D:

for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
{
one[j + i*2] = array[i,j];
}

Regards,
Emad

Tonyukuk said:
For example I have an 2D array.
int [,] array=new int[2,2];
and I can convert it into one[4]
how can I do that ?
 
Back
Top