private static void Main() { var stack = new CustomStack <int>(); for (int i = 0; i < 8; i++) { stack.Push(i); } Console.WriteLine(stack); Console.WriteLine("Count: {0}", stack.Count); stack.Push(100); Console.WriteLine(stack); Console.WriteLine("Count: {0}", stack.Count); Console.WriteLine(stack.Peek()); stack.Pop(); Console.WriteLine(stack); Console.WriteLine("Count: {0}", stack.Count); }
public static void Main() { var stack = new CustomStack <int>(); new List <int> { 1, 2, 3, 4, 5 }.ForEach(x => stack.Push(x)); while (stack.Count > 0) { Console.WriteLine(stack.Pop()); } }
public static void Main() { var stack = new CustomStack <int>(); for (int i = 0; i < 50; i++) { stack.Push(i); } Console.WriteLine("The items in the stack are:"); int stackCount = stack.Count; for (int i = 0; i < stackCount; i++) { Console.Write("{0} ", stack.Pop()); } Console.WriteLine(); }
public static void Main(string[] args) { var stack = new CustomStack <int>(); stack.Push(50); stack.Push(3); stack.Push(56); stack.Push(50); stack.Push(3); stack.Push(56); stack.Push(50); stack.Push(3); stack.Push(56); stack.Push(50); stack.Push(3); stack.Push(56); Console.WriteLine(stack.Peek()); stack.Pop(); var a = stack.Pop(); Console.WriteLine(a); Console.WriteLine(stack.Contains(56)); }