Glam Prestige Journal

Bright entertainment trends with youth appeal.

What's the simplest way to join one or more arrays (or ArrayLists) in Visual Basic?

I'm using .NET 3.5, if that matters much.

0

1 Answer

This is in C#, but surely you can figure it out...

int[] a = new int[] { 1, 2, 3, 4, 5 };
int[] b = new int[] { 6, 7, 8, 9, 10 };
int[] c = a.Union(b).ToArray();

It will be more efficient if instead of calling "ToArray" after the union, if you use the IEnumerable given instead.

int[] a = new int[] { 1, 2, 3, 4, 5 };
int[] b = new int[] { 6, 7, 8, 9, 10 };
IEnumerable<int> c = a.Union(b);
2