我有两个枚举,它们引用的元素完全相同,但是为什么Equals不会返回true。
另外一个问题,下面的代码可以比较每个元素,但肯定有更优雅的方法。
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;