c#比较两个List相等

1、if(ListA.Count == ListB.Count && ListA.Count(t => !ListB.Contains(t)) == 0)

数量相等,元素值相等即为True;与元素顺序无关;

List<int> A = new List<int> {1,2,3};

List<int> B = new List<int> {1,3,2};

A == B;

 

2、if (ListA.SequenceEqual(ListB))

数量相等,值相等,顺序一样时为True;

posted @ 2015-07-19 00:42  YYRise  阅读(11684)  评论(5编辑  收藏  举报