To compare the lists, use SequenceEqual
(MSDN)
In your case, you can combine it with Any
:
var containsListToFind = parentList.Any(x => x.SequenceEqual(listToFind));
Contains
won't work because it uses the default .Equals
method of the objects in the list. For List<T>
, that is a reference comparison, not a value comparision. Since listToFind
is a different object than the one in parentList
, the references are different and Contains
won't find anything.