Computer Science, asked by pravdeep6623, 1 year ago

How to convert a 2D array into 1D array in C#?

Answers

Answered by Anonymous
0

\huge\red{Answer}

Before you start you should be consistent about which order to follow(row wise or column wise).

If it’s row wise then

m = denotes rows starting from 0 to max row

n = denotes columns starting from 0th column to max column

new_position = m * n + n

for(int i=0; i<m; i++){

for(int j=0;j<n;j++){

int position = i*n + j;

newArr[position] = arr[i][j];

}

}

HOPE IT HELPS YOU !!

Similar questions