C#合并的2集不同的项目 [英] C# merge distinct items of 2 collections

查看:107
本文介绍了C#合并的2集不同的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找第二ICollection的鲜明的项目添加到现有的一个性能方法。我使用.NET 4

I'm looking for a performant way to add distinct items of a second ICollection to an existing one. I'm using .NET 4.

推荐答案

这应该这样做:

list1.Union(list2).Distinct(aCustomComparer).ToList()

这篇关于C#合并的2集不同的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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