The simplest way would be to check if any of the second list contains the items from the first
var listAItems = listA.SelectedItems var listBItems = listB.SelectedItems if(listAItems.Count == listBItems.Count && listAItems.Any(i => !listBItems.Contains(i))) //Something missing else //All there
Note: this works for all IEnumerables
I'm not sure if this answer would be more efficient for your usage than the one in the duplicate since this will return true as soon as it finds an entry that doesn't exist - The duplicates answer has the possibility to return the items that are missing
var missing = listA.SelectedItems.Except(listB.SelectedItems); if(missing.Any()) //something missing use the missing variable to see what
A, B, C, D, Eand likewise for listbox B...and in that order for both boxes. So, if A, B and C are selected in box A and likewise for B, the statement would return true. If box A selected was A and C, while box B was A, D, it would return false.