using System.Collections;
namespace MyDictionary
{//字典集合类
class IDic:DictionaryBase
{
public IDic()
{
}
public void Add(string name,string IP)
{
base.InnerHashtable[name] = IP;
}
public string Item(string name)
{
return base.InnerHashtable[name].ToString();
}
public void Remove(string name)
{
base.InnerHashtable.Remove(name);
}
}
}
//示例程序
class Program
{
static void Main(string[] args)
{
IDic IPDic = new IDic();
IPDic.Add("Wei", "715547");
IPDic.Add("Wei02", "715548");
IPDic.Add("Wei03", "715549");
Console.WriteLine(IPDic.Item("Wei"));
DictionaryEntry[] ips = new DictionaryEntry[IPDic.Count];
IPDic.CopyTo(ips,0);
for (int i = 0; i <= ips.GetUpperBound(0); i++)
{
Console.WriteLine(ips[i].Key+":"+ips[i].Value);
}
}
}