我创建一个从列表派生的类...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)
{
...
}
...并请有值完成的列表比较。
什么是最好的方法......?