static void Main(string[] args) { var stack = new Stack(); const string menu = "\n1. Push\n2. Contains?\n3. Pop\n4. Clear\n5. Quit\n\nInput the number of menu: "; string line; var done = false; GetLine(args, ref stack); do { Console.Clear(); Console.WriteLine("Stack(" + stack.Count + "): " + (stack.ToString() != "" ? stack.ToString() : "null")); Console.WriteLine(menu); var key = Console.ReadLine(); switch (key) { case "1": Console.Write("\nInput the line: "); line = Console.ReadLine(); stack.Push(line); break; case "2": Console.WriteLine("\nInput a line: "); line = Console.ReadLine(); Console.WriteLine("\n" + stack.Contains(line)); Console.ReadLine(); break; case "3": stack.Pop(); break; case "4": stack.Clear(); break; case "5": done = true; break; case "6": var a = stack.ToArray(); for (int i = 0; i < stack.Count; i++) Console.WriteLine(a[i]); Console.ReadLine(); break; } } while (!done); }