我有两个arrays:
var students = new [] {"Elisa" ,"Sarah", "Frank","Frederic"};
var votes = new[] {90, 70, 40,80};如果可能的话,我如何使用linq打印这样的东西?
"Elisa 90"
"Sarah 70"
"Frank 40"
"Frederic 80"发布于 2014-09-28 12:08:11
您可以使用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.
https://stackoverflow.com/questions/26084699
复制相似问题