2
我有两个arrays
:合并两个数组使用LINQ
var students = new [] {"Elisa" ,"Sarah", "Frank","Frederic"};
var votes = new[] {90, 70, 40,80};
如何打印像这样使用linq
如果可能的话?
"Elisa 90"
"Sarah 70"
"Frank 40"
"Frederic 80"
我有两个arrays
:合并两个数组使用LINQ
var students = new [] {"Elisa" ,"Sarah", "Frank","Frederic"};
var votes = new[] {90, 70, 40,80};
如何打印像这样使用linq
如果可能的话?
"Elisa 90"
"Sarah 70"
"Frank 40"
"Frederic 80"
您可以使用Linq.Zip
var students = new[] { "Elisa", "Sarah", "Frank", "Frederic" };
var votes = new[] { 90, 70, 40, 80 };
var studendsAndVotes = students.Zip(votes, (student, vote) => student + " " + vote);
从MSDN
Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.
这是快...'+ 1' – 2014-09-28 12:09:32
感谢你,因为太容易 – dav 2014-09-28 12:16:04