Reputation: 394
I have the following collections:
string[] names1 = { "Kareem", "Mohammed", "Borai" };
string[] names2 = { "Kareem", "Mohammed", "Borai" };
string[] names3 = { "Kareem", "Mohammed", "Borai" };
And I looking for code like this:
bool isEqual = names1.SequenceEqual(names2).SequenceEqual(names3);
How to achieve that?
Upvotes: 0
Views: 67
Reputation: 101701
If there are more collections to check put them into another collection and use All
method
bool isEqual = new [] { names2, names3, ... }.All(names1.SequenceEqual);
Upvotes: 1
Reputation: 89315
How about using simple &&
operator :
bool isEqual = names1.SequenceEqual(names2) && names1.SequenceEqual(names3);
Upvotes: 5