public class GoodList : CollectionBase
{
public virtual int Add(T fruit)
{
return InnerList.Add(fruit);
}
public new void RemoveAt(int index)
{
InnerList.RemoveAt(index);
}
public T GetItem(int index)
{
return (T)List[index];
}
public void Set(int index, T fruit)
{
this.RemoveAt(index);
this.Add(fruit);
}
}
public class Program
{
static void Main(string[] args)
{
Fruti f1 = new Fruti("n1001","苹果","1.5",6);
Fruti f2 = new Fruti("n1002", "香蕉", "0.4", 4);
Fruti f3 = new Fruti("n1003", "橘子", "0.5", 10);
Drink d1 = new Drink("n2001","绿茶","3",2);
Drink d2 = new Drink("n2002", "红茶", "2.5", 4);
GoodList gd=new GoodList();