Possible Duplicate:
Comparing two collections for equality
I have two lists
List<int> Foo = new List<int>(){ 1, 2, 3 };
and
List<int> Bar = new List<int>(){ 2, 1 };
To find out if they have same elements or not I did
if(Foo.Except(Bar).Any() || Bar.Except(Foo).Any())
{
//Do Something
}
but this requires two bool evaluations. First it does Foo.Except(Bar).Any()
and then Bar.Except(Foo).Any()
. Is there a way to do this in single evaluation?