public static void GetLine(string[] args, ref StackShort stack) { foreach (var value in args) { string[] sub = value.Split(new[] { "=" }, StringSplitOptions.RemoveEmptyEntries); if (sub[0] == "/a") stack.Push(sub[1]); } }
static void Main(string[] args) { var stack = new StackShort(); 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; } } while (!done); }