[csharp] view plaincopyprint?
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();
}
}
}
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();
}
}
}