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;


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM