Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Join arrays in VB.NET [duplicate]

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.

like image 461
jimtut Avatar asked Oct 21 '08 00:10

jimtut


2 Answers

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);
like image 165
TheSoftwareJedi Avatar answered Sep 21 '22 02:09

TheSoftwareJedi


You can take a look at this thread that's titled Merging two arrays in .NET.

like image 39
mwilliams Avatar answered Sep 22 '22 02:09

mwilliams