I have 2 lists I am trying to compare. I execute the following and I get a false
value returned:
var areIdentical = list1.SequenceEqual(list2, myFileCompare);
That part is working. My lists are NOT equal. The problem is, I'm using the following command to try to find the differences:
var fileDiff = (from file in list1
select file).Except(list2, myFileCompare);
My problem is, fileDiff
is returning an empty result set. Since I know they are NOT identical, shouldn't I get something returned? Perhaps my query is wrong on this. Any help would be appreciated! By the way, I can post more of my code, if you really need it, however, this should suffice.
You wouldn't get anything if:
list2
contained everything in list1
but also extra itemsAssuming you don't care about the ordering, you can use:
var extraItemsInList2 = list2.Except(list1);
var extraItemsInList1 = list1.Except(list2);
If you do care about the order, you'll need to work out exactly how you want the differences to be represented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With