Tôi có hai số đếm với cùng một yếu tố tham chiếu chính xác, và tự hỏi tại sao Equals không đúng.Sự bình đẳng giữa hai số điện thoại
Như một câu hỏi phụ, mã dưới đây để so sánh từng yếu tố công trình, nhưng phải có một cách thanh lịch hơn
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;
bản sao có thể có của http://stackoverflow.com/questions/876508/what-is-the-best-way-to-check-two-listt-lists-for-equality-in-c – Berryl
bản sao có thể có của [ Có phương pháp tích hợp nào để so sánh các bộ sưu tập trong C#?] (Http://stackoverflow.com/questions/43500/is-there-a-built-in-method-to-compare-collections-in-c) – nawfal