码迷,mamicode.com
首页 > Windows程序 > 详细

c#比较两个List相等

时间:2015-07-19 01:20:07      阅读:894      评论:0      收藏:0      [点我收藏+]

标签:

1、if(ListA.Count == ListB.Count && ListA.Count(t => !ListB.Contains(c)) == 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;

c#比较两个List相等

标签:

原文地址:http://www.cnblogs.com/YYRise/p/4657966.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!