使用LINQ在新列表中合并两个列表 [英] Merged Two list in new List using LINQ

查看:232
本文介绍了使用LINQ在新列表中合并两个列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用LINQ将这两个列表合并为一个新列表.

I need to combine the 2 lists into a new List using LINQ

推荐答案

Try
Try
var result = from item1 A item in first
                    from item1 B in second
                    select new{ A, B};


要添加到Abinav的解决方案中,而不使用Linq:
To add to Abinav''s solution, not using Linq:
List<myClass> newList = new List<myClass>();
newList.AddRange(oldListA);
newList.AddRange(oldListB);

这具有类型安全的优点.

This has the advantage of being typesafe.


这篇关于使用LINQ在新列表中合并两个列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆