Solved

Compare 2 list collections for equality

Posted on 2012-04-03
2
635 Views
Last Modified: 2013-12-27
I need to compare two custom object lists to see if they both contain the same objects. Each object has an Id property. The lists will not contain duplicates and may not be the same length.
0
Comment
Question by:ifetayo
2 Comments
 
LVL 23

Accepted Solution

by:
wdosanjos earned 100 total points
Comment Utility
Please try:
bool isEqual = (list1.Count == list2.Count)
            && (list1.TrueForAll( e1 => list2.Any(e2 => e2.Id == e1.Id)));

Open in new window

0
 

Author Closing Comment

by:ifetayo
Comment Utility
Sorry so late with this. I must have figured out a way to solve my problem shortly after asking this question, but for the life of me, I can't remember what I did. This is a good solution though and I have no doubt that it would work so I'm going to award the points anyway. Thanks a bunch.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

With Windows Embedded Handheld, called Windows Mobile, Microsoft re-designed the user interface. The Start Icon moved down to the bottom, inside the menu bar area.   If you need to hide the Start Icon and/or the SIP (soft input panel, softwar…
I recently asked a question (http://www.experts-exchange.com/Programming/Smartphones/Android/Q_28684946.html) about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now