c# foreach语句遍历堆栈(stack)
代码:
复制代码 代码示例:
using System;
using System.Collections;
public class StacksW3
{
static void Main(string[] args)
{
Stack a = new Stack(10);
int x = 0;
a.Push(x);
x++;
a.Push(x);
foreach (int y in a)
{
Console.WriteLine(y);
}
a.Pop();
a.Clear();
}
}