我搜索了我的問題的解決方案,但我想我再次嘗試錯誤的關鍵字。 我想比較兩個ObservableCollections。 Equals和SequenceEqual不起作用。比較兩個系列
var properties = typeof(MyClass).GetProperties();
for (var i = 0; i < list1.Count(); i++)
{
foreach (var property in properties)
{
var value1 = property.GetValue(list1[i]);
var value2 = property.GetValue(list2[i]);
if (value1 != value2)
{
return false;
}
}
}
值1和值2都爲「真」,但它跳進return語句:
我使用反射寫了某種比較方法。
Ofcourse我可以用MyClass的每個屬性手動執行它,但這並不是很舒服。 希望你能告訴我我的錯誤在哪裏。
可能重複[比較兩個集合的相等](http://stackoverflow.com/questions/50098/comparing-two-collections-for-equality) – nathanchere