1

I'd like to know if there is a simple way to union two 2-Darrays.

Here is an example

int[,] array1 = new int[,] { { 1, 2 }, { 3, 4 }};

int[,] array2 = new int[,] { {5, 6 },  { 7, 8 }};

int[,] Union = new int[,] { { 1, 2 }, { 3, 4 },{5, 6 },  { 7, 8 }};
Kroll DU
  • 79
  • 1
  • 10
  • 3
    http://stackoverflow.com/questions/1547252/how-do-i-concatenate-two-arrays-in-c – Save Jul 25 '15 at 21:38
  • @ Save I want to union two 2D arrays not two 1D arrays.Is there a way to do so? – Kroll DU Jul 25 '15 at 21:54
  • What does it mean to union two 2D arrays? Your example concats the rows of `2` after the rows of `1`, but what if the number of columns are different between `1` and `2`? Multidimensional arrays aren't jagged, so this operation is vague. – 31eee384 Jul 26 '15 at 14:50
  • 1
    According to MSDN, for `Array.Copy` ["When copying between multidimensional arrays, the array behaves like a long one-dimensional array, where the rows (or columns) are conceptually laid end-to-end"](https://msdn.microsoft.com/en-us/library/z50k9bft(v=vs.110).aspx). So treating your 2D array this way, you can easily use answers from the marked question and just use both dimensions multiplied together to get the length. – 31eee384 Jul 26 '15 at 14:54

0 Answers0