c# - Linq 中的 Enumerable.Zip 扩展方法有什么用?

标签 c# linq enumerable

Enumerable.Zip有什么用Linq 中的扩展方法?

最佳答案

Zip 运算符使用指定的选择器函数合并两个序列的相应元素。

var letters= new string[] { "A", "B", "C", "D", "E" };
var numbers= new int[] { 1, 2, 3 };
var q = letters.Zip(numbers, (l, n) => l + n.ToString());
foreach (var s in q)
    Console.WriteLine(s);

输出

A1
B2
C3

关于c# - Linq 中的 Enumerable.Zip 扩展方法有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5122737/

相关文章:

c# - 如何在 C# 中将 XDocument 附加到 MailMessage?

ruby - Ruby 中接下来的 invalid 是什么?

c# - IEnumerable 没有 Count 方法

ruby - 如何在一行内遍历这个散列?

c# - 使用 LINQ 编辑 XML 输出

c# - 从数据库和缓存中获取 AppSettings

C#、Linq2Sql : Is it possible to concatenate two queryables into one?

c# - 如何制作一个消耗约 500 个 RSS 并在数据库中保存新项目的 Web 服务?

c# - 从 Linq To Sql 对象获取字段名称

c# - LINQ:将某些对象属性选择到同一对象中