How do I concatenate two arrays in C#?
Asked 07 September, 2021
Viewed 2.8K times
  • 60
Votes
int[] x = new int [] { 1, 2, 3};
int[] y = new int [] { 4, 5 };

int[] z = // your answer here...

Debug.Assert(z.SequenceEqual(new int[] { 1, 2, 3, 4, 5 }));

Right now I use

int[] z = x.Concat(y).ToArray();

Is there an easier or more efficient method?

23 Answer