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.
+3
A:
You can take a look at this thread that's titled Merging two arrays in .Net
mwilliams
2008-10-21 00:19:24
+2
A:
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);
TheSoftwareJedi
2008-10-21 01:24:17
The OP asked to join two arrays together. Not find the union which will not keep the duplicates. I do believe concat is what they might have been looking for.
uriDium
2010-08-12 14:51:57
You are correct. "Join" has several meanings, but I should have understood it better.
TheSoftwareJedi
2010-08-30 13:52:27
A:
Can not add comments, so putting this in an answer.
The comment I wanted to make for the answer given by "TheSoftwareJedi" about using Union. The only thing I will be concerned over here is that Union give you only unique elements.
If you do want all the duplicate elements also then concat may be thing. And there is a previous post doing something similar.
Biswanath
2008-12-01 14:04:51