我創建一個從列表派生的類...System.Collections.Generic.List的等效方法<T> ...?
public class MyList : List<MyListItem> {}
我已經覆蓋MyListItem總量等於...
public override bool Equals(object obj)
{
MyListItem li = obj as MyListItem;
return (ID == li.ID); // ID is a property of MyListItem
}
我想有MyList對象中的Equals方法也會比較列表中的每個項目,並調用每個MyListItem對象上的Equals()。
這將是很好只需撥打...
MyList l1 = new MyList() { new MyListItem(1), new MyListItem(2) };
MyList l2 = new MyList() { new MyListItem(1), new MyListItem(2) };
if (l1 == l2)
{
...
}
...並請有值完成的列表比較。
什麼是最好的方法......?