0

Whats the easiest/ most canonical way to convert from a multidimensional array into an array of arrays and vice versa?

For example, what is an elegant way to convert the following array of arrays int[][]

int[][] arrayArray = new int[][] {
    new int[] { 1, 2 },
    new int[] { 3, 4 },
    new int[] { 5, 6 },
    new int[] { 7, 8 }
};

Into an multidimensional int[,] which looks like:

int[,] array2D = new int[,] { 
    { 1, 2 }, 
    { 3, 4 }, 
    { 5, 6 }, 
    { 7, 8 }
};

Thanks!

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
flakes
  • 21,558
  • 8
  • 41
  • 88

0 Answers0