2014-09-23 61 views
0

我有兩個相同大小的數組。如何從兩個其他數組創建數組?

Dim arr1() As String = {"Hello", "world", "I'm", "some", "text"} 
Dim arr2() As String = {"Hello2", "world2", "I'm2", "some2", "text2"} 

我需要從這兩個數組中創建另一個*一個數組。

編輯: 這樣的事情。

Dim arr3(0) As String = {"Hello", "Hello2"} 
Dim arr3(1) As String = {"world", "world2"} 
Dim arr3(2) As String = {"I'm", "I'm2"} 
Dim arr3(3) As String = {"some", "some2"} 
Dim arr3(4) As String = {"text", "text2"} 

回答

0

您正在尋找Zip

Enumerable.Zip(中T第一,TSecond,TResult)方法

應用指定d函數爲兩個序列的相應元素,產生一系列結果。

實施例:

Dim arr1() As String = {"Hello", "world", "I'm", "some", "text"} 
Dim arr2() As String = {"Hello2", "world2", "I'm2", "some2", "text2"} 

Dim arr3 = arr1.Zip(arr2, Function(a, b) {a, b}).ToArray() 
0

你也可以使用Enumerable.Zip

Dim res = arr1.Zip(arr2, Function(a,b) {a,b}) 
相關問題