两份清单C#的区别 [英] Difference of two lists C#
本文介绍了两份清单C#的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个字符串列表,它们都是〜300,000行.清单1比清单2多了几行.我想做的是在清单1中找到但不在清单2中的字符串.
I have two lists of strings both of which are ~300,000 lines. List 1 has a few lines more than List 2. What I'm trying to do is find the strings that in List 1 but not in List 2.
考虑到我必须比较多少个字符串,Except()
是否足够好?还是有更好(更快)的东西?
Considering how many strings I have to compare, is Except()
good enough or is there something better (faster)?
推荐答案
在内部,可枚举的Except
扩展方法使用Set<T>
进行计算.它将和其他方法一样快.
Internally the enumerable Except
extension method uses Set<T>
to perform the computation. It's going to be as least as fast as any other method.
选择list1.Except(list2)
.
它将为您提供最佳性能和最简单的代码.
It'll give you the best performance and the simplest code.
这篇关于两份清单C#的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文