我正在尝试使用for next循环迭代数组并组合其字符串 我只能得到第一个数组。不知道如何编写代码与第二个组合并使用VB.NET创建第三个数组。你能帮忙吗?
前:
arrLetters() As String = {"A", "B", "C", "D", "E", "F", "G", "H", "I"}
arrNumbers() As String = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}
结果array(81) = {A1, A2 ...A9, B1, B2...B9, ...I9}
答案 0 :(得分:1)
在C#中它将是:
from letter in arrLetters
from number in arrNumbers
select letter + number
在VB中,结果进入数组变量:
Dim array = (From letter In arrLetters
From number In arrNumbers
Select letter + number).ToArray()
答案 1 :(得分:0)
使用以下逻辑(在C#中)
var arrLetters= new string[] {"A", "B", "C", "D", "E", "F", "G", "H", "I"};
var arrNumbers = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
var array = arrLetters.Zip(arrNumbers, (letter, word) => letter + word);
希望这会有所帮助:)