using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyCollection
{
class Program
{
static void Main(string[] args)
{
Collection names = new Collection();
names.Add("David");
names.Add("Bernica");
names.Add("Raymond");
foreach (Object name in names)
{
Console.WriteLine(name);
}
}
}
/// <summary>
/// 构造自己和集合类
/// </summary>
public class Collection:CollectionBase
{
// 增加
public void Add(Object item)
{
this.InnerList.Add(item);
}
// 删除
public void Remove(Object item)
{
this.InnerList.Remove(item);
}
// 总数,用new 关键字隐藏父类实现
public new int Count()
{
return InnerList.Count;
}
// 清空
public new void Clear()
{
this.InnerList.Clear();
}
}
}
转载于:https://www.cnblogs.com/jiangu66/archive/2013/04/22/3036567.html