如何比较C#3.0中的两个通用列表? [英] How to compare two generic lists in C# 3.0?
本文介绍了如何比较C#3.0中的两个通用列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Possible Duplicate:
Is there a built-in method to compare collections in C#?
与C#3.0中的泛型两个通用列表进行比较的最佳方式是什么?
What is the best way to compare to generic two generic lists in C# 3.0?
推荐答案
- $ b如果您想比较任何元素顺序,请尝试 UnorderedEqual< T> 方法。 $ b
- C#列表元素平等
- C# List Element Equality
否则:
Otherwise:
var list1 = new List<int> { 1, 2, 3 };
var list2 = new List<int> { 1, 2, 3 };
var areSame = Enumerable.SequenceEqual(list1, list2);
这篇关于如何比较C#3.0中的两个通用列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文