📜  foreach 两个数组 c# 代码示例

📅  最后修改于: 2022-03-11 14:49:09.799000             🧑  作者: Mango

代码示例1
var numbers = new [] { 1, 2, 3, 4 };
var words = new [] { "one", "two", "three", "four" };

var numbersAndWords = numbers.Zip(words, (n, w) => new { Number = n, Word = w });
foreach(var nw in numbersAndWords)
{
    Console.WriteLine(nw.Number + nw.Word);
}