How to convert a 2D array into 1D array in C#?
Answers
Answered by
0
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
World Languages,
7 months ago
English,
7 months ago
Math,
7 months ago
Computer Science,
1 year ago
Hindi,
1 year ago
Math,
1 year ago