Reputation: 109
if i have an array like this
A
B
C
D
E
and a second array like this
A
B
C
D
E
how to creat new array from the first tow arrays so the new array be like this
AA
BB
CC
DD
EE
i try this
Dim urls() As String
For i As Int32 = 0 To array1.Length - 1
urls = array1.Select(Function(o) array2(i) & o).ToArray()
next
but the output was like this
EA
EB
EC
ED
EE
Upvotes: 0
Views: 80
Reputation: 1556
Try this...
Dim array1() As String = {"A", "B", "C", "D", "E"}
Dim array2() As String = {"A", "B", "C", "D", "E"}
Dim urls() As String
urls = array1.Select(Function(o, p) o & array2(p)).ToArray()
Hope that helps....
Upvotes: 1
Reputation: 2280
you are using for loop and lambda query both which shouldn't be the case. Try the below code
Dim urls() As String
urls = array1.Select(Function(item, index) item & array2(index)).ToArray()
OR
Dim urls() As String
urls = array1.Zip(array2, Function(x, y) x & y).ToArray()
Upvotes: 2