会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
robot.h--为之漫笔
上海优化公司
上海装修公司
博客园
首页
订阅
管理
System.Collections.Stack
using
System;
using
System.Collections;
namespace
_08_04
{
public
class
Class_08_04
{
public
static
void
Main(String[] args)
{
Stack s
=
new
Stack();
s.Push(
"
Cat
"
);
s.Push(
"
Dog
"
);
s.Push(
"
Bird
"
);
s.Push(
"
Dinosaur
"
);
s.Push(
"
Human
"
);
Console.WriteLine(
"
堆栈中有元素 {0} 个
"
, s.Count);
Console.WriteLine(
"
用 IEnumerator 访问所有元素:
"
);
IEnumerator enu
=
s.GetEnumerator();
while
(enu.MoveNext())
{
Console.WriteLine(
"
{0}\t 堆栈中有元素 {1} 个
"
, enu.Current.ToString(), s.Count);
}
Console.WriteLine();
Console.WriteLine(
"
从栈顶Pop所有元素
"
);
while
(s.Count
>
0
)
{
Console.WriteLine(
"
{0}\t 堆栈中有元素 {1} 个
"
, s.Pop().ToString(), s.Count);
}
}
}
}
posted @
2007-04-27 15:08
roboth
阅读(
243
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告