If you have two lists:
List<string> list1 = new List<string>() { "ABC", "CDE" };
List<string> list2 = new List<string>() { "ABC" };
list1.Except(list2).Any()
returns true
but if you do the opposite
list2.Except(list1).Any()
returns false
I thought list2.Except(list1).Any()
should return true
as well but I was wrong.
Is there a way to compare two list and check if there is differences in the two lists regardless of which order the items is in each list?
I know that there are several ways to do this. With a for loop or with Linq which also results in a for loop. But I am doing this on millions of lists so speed is key.