我有两个具有完全相同参考元素的枚举,并且想知道为什么 Equals 不会是真的。
作为一个附带问题,下面用于比较每个元素的代码有效,但必须有一种更优雅的方式
var other = (ActivityService) obj;
if (!AllAccounts.Count().Equals(other.AllAccounts.Count())) return false;
for (int i = 0; i < AllAccounts.Count(); i++) {
if (!AllAccounts.ElementAt(i).Equals(other.AllAccounts.ElementAt(i))) {
return false;
}
}
return true;