首页 > 其他 > 详细

7.30

时间:2016-07-30 18:28:15      阅读:145      评论:0      收藏:0      [点我收藏+]

特殊技集合

初始化 干草堆 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();

 

7.30

原文:http://www.cnblogs.com/power8023/p/5721311.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!