我有以下收藏品:
string[] names1 = { "Kareem", "Mohammed", "Borai" };
string[] names2 = { "Kareem", "Mohammed", "Borai" };
string[] names3 = { "Kareem", "Mohammed", "Borai" };
我正在寻找这样的代码:
bool isEqual = names1.SequenceEqual(names2).SequenceEqual(names3);
如何实现?
答案 0 :(得分:5)
如何使用简单的&&
运算符:
bool isEqual = names1.SequenceEqual(names2) && names1.SequenceEqual(names3);
答案 1 :(得分:1)
如果有更多要检查的集合,请将它们放入另一个集合并使用All
方法
bool isEqual = new [] { names2, names3, ... }.All(names1.SequenceEqual);