根据订单合并两个或多个列表 [英] Merge Two or more list according to order
本文介绍了根据订单合并两个或多个列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个列表
List<string> Name = new List<string>();
List<string> Address = new List<string>();
无论是有30个数据列表。我要合并这两个名单,得到像
Both the lists having 30 data. I want to merge both the lists to get a complete Information lists like
List<string, string> CompleteInformation = new List<string, string>();
另外,如果我想合并两个以上的列表在一个它是如何完成的。
Also if I want to merge more than two list in one how it can be done.
推荐答案
您正在寻找邮编
方法:
var CompleteInformation = Name.Zip(Address, (n, a) => new { Address = a, Name = n }).ToList();
为您提供了匿名类型实例的列表,以及两个属性:地址
I 名称
。
更新
您可以致电邮编
更多然后一次:
You can call Zip
more then once:
var CompleteInformation
= Name.Zip(Address, (n, a) => new { Address = a, Name = n })
.Zip(AnotherList, (x, s) => new { x.Address, x.Name, Another = s })
.ToList();
这篇关于根据订单合并两个或多个列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文