Your Intersect
returns IEnumerable<string>
. Therefore you are comparing two instances of IEnumerable. As L.B mentioned in the comments, you can use Any
to check whether the resultant IEnumerable<string>
is empty.
bool empty = !a.Intersect(b).Any();
Another way would be to use HashSet's SetEquals
method.
var ab = new HashSet<string>(a.Intersect(b));
bool equal = ab.SetEquals(b.Intersect(a));