如果我有这样的数组
A
B
C
D
E
和第二个这样的数组
A
B
C
D
E
如何从第一个两个数组创建新数组,这样新数组就像这样
AA
BB
CC
DD
EE
我试试这个
Dim urls() As String
For i As Int32 = 0 To array1.Length - 1
urls = array1.Select(Function(o) array2(i) & o).ToArray()
next
但输出就像这样
EA
EB
EC
ED
EE
答案 0 :(得分:2)
你正在使用for循环和lambda查询两者都不应该是这种情况。 请尝试以下代码
Dim urls() As String
urls = array1.Select(Function(item, index) item & array2(index)).ToArray()
或强>
Dim urls() As String
urls = array1.Zip(array2, Function(x, y) x & y).ToArray()
答案 1 :(得分:1)
试试这个......
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()
希望有所帮助....