日期:2014-05-18 浏览次数:20849 次
1. 继承 List<T> 2. 新建方法: RemoveMaxItem() RemoveMinItem() 3. 实现方法: public void RemoveMaxItems() { this.RemoveAll(e => e.Equals(this.Max())); } public void RemoveMinItems() { this.RemoveAll(e => e.Equals(this.Min())); } 4. 测试: MyList<int> list = new MyList<int> { 11, 2, 2, 2, 5, 6, 7, 8, 9, 10, 11 }; Console.WriteLine(String.Join<int>(" - ", list)); list.RemoveMaxItems(); Console.WriteLine(String.Join<int>(" - ", list)); list.RemoveMinItems(); Console.WriteLine(String.Join<int>(" - ", list));