using System;
using System.Collections.Generic;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
int length = 100000;
Stack<int> stack = new Stack<int>(length);
for (int i = 0; i < length; i++)
{
stack.AddItem(i);
}
for (int i = 0; i < length; i++)
{
stack.OutputItem();
}
Console.ReadKey();
}
}
class Stack<T>
{
private T[] container;
private int count = 0;
public void AddItem(T item)
{
if(count<container.Length)
container[count++] = item;
}
public void OutputItem()
{
if(count>0)
Console.WriteLine(container[--count]);
}
public Stack(int length)
{
container = new T[length];
}
}
}