using System;
using System.Collections.Generic;
using System.Collections; // For old-style ArrayList.
class StackSample
{
static void Main(string[] args)
{
Stack movieStack = new Stack();
movieStack.Push ("Sinners");
movieStack.Push ("Band of Brothers");
movieStack.Push ("13 Hours");
movieStack.Push ("Fast and Furious");
movieStack.Push ("The Accountant");
movieStack.Push ("Pulp Fiction"); // ... wait a minute ... its was Caddy Shack, Caddy Shack II was a really bad movie
movieStack.Pop (); // remove Caddy Shack II
movieStack.Push ("Avatar"); // add Caddy Shack to my list
Console.WriteLine("Contents of Pat's 6 favorite comedy movies ...");
// print all of my favorite movies
foreach(string movie in movieStack) {
Console.WriteLine(movie);
} // foreach
Console.WriteLine("\n\nPopping the Stack ...\n"); // skip a few lines
while(movieStack.Count > 0) {
string movie = (string) movieStack.Pop ();
Console.WriteLine("Popping {0}", movie );
} // while
} // main
} // class Stack Sample