using System; using System.Collections; namespace Collections { class Program { static void Main(string[] args) { Stack intStack = new Stack(); // Populate the Stack for (int i = 0; i < 5; i++) { intStack.Push((i + 1) * 10); } Console.WriteLine("Here are the items in the Stack: "); //Print each member of the Stack foreach (int i in intStack) { Console.Write("{0} ", i.ToString()); } // Displays the topmost member of the Stack without removing it Console.Write("\nThe value of the topmost member is: {0} \n", intStack.Peek().ToString()); // Removes the topmost item from the Stack and displays the remaining items intStack.Pop(); Console.Write("The topmost item has now been removed. \nNow the remaining members are: "); //Print each member of the Stack foreach (int i in intStack) { Console.Write("{0} ", i.ToString()); } System.Console.ReadKey(); } } }