7.30

特殊技集合

初始化 干草堆 stack集合
先进后出,一个一个的赋值,一个一个的取值

 

添加元素(推送)   push

Console.WriteLine(ss.Count); 个数

 

Console.WriteLine(ss.Pop());
弹出

 

clear 清空集合

 

enqueue 进队列集合

 

dequeue   出列队集合

 

哈希表集合
先进后出,一个一个赋值,但是只能一起取值
初始化
Hashtable ht = new Hashtable();
ht.Add(1,"可口可乐");
ht.Add(2, "雪碧");
ht.Add(3, "百事可乐");
ht.Add(4, "芬达");
ht.Add(5, "美年达");
移除(某个key值的位置的元素)
ht.Remove(3);
判断是否包含
Console.WriteLine( ht.Contains(5));
Console.WriteLine(ht.Count);
foreach (int aa in ht.Keys)
{
Console.WriteLine(aa);
}
foreach (string ss in ht.Values)
{
Console.WriteLine(ss);
}

 

使用枚举类型来读取(表格样式)
IDictionaryEnumerator ide = ht.GetEnumerator();
while(ide.MoveNext())
{
Console.WriteLine(ide.Key+"\t"+ide.Value);
}
Console.ReadLine();

 

posted @ 2016-07-30 17:06  涤荡轮回  阅读(89)  评论(0编辑  收藏  举报