The stack represents a last-in-first-out collection of objects.
Using system;using System.Collections; Namespace collectionsapplication{class Program {static void Main (string[] args) {Stack s t = new Stack (); St. Push (' A '); St. Push (' M '); St. Push (' G '); St. Push (' W '); Console.WriteLine ("Current stack:"); foreach (char c in St) {Console.Write (c + ""); } Console.WriteLine (); St. Push (' V '); St. Push (' H '); Console.WriteLine ("The next poppable value in stack: {0}", St. Peek ()); Console.WriteLine ("Current stack:"); foreach (char c in St) {Console.Write (c + ""); } Console.WriteLine (); Console.WriteLine ("Removing values"); St. Pop (); St. Pop (); St. Pop (); Console.WriteLine ("Current stack:"); foreach (char c in St) {Console.Write (c + ""); } } }}
These are the contents of the C # stack (stacks), more about topic.alibabacloud.com (www.php.cn)!