Mono Class Library: System.Collections NamespaceSystem.Collections.Stack Class |
See Also: Stack Members
|
The stack is a collection supporting only the push, pop, and peek operations. The push method puts an object onto the end of the stack. The peek method returns the most recent object placed on the stack. The pop method removes the most recent object placed on the stack and returns it.
A simple stack:
[Edit]
C# Example using System; using System.Collections; public class SamplesStack { public static void Main (string [] args) { Stack stack = new Stack(); stack.Push("Hello"); stack.Push("World"); stack.Push("!"); Console.WriteLine("the last value of the stack {0}", stack.Peek()); stack.Pop(); stack.Pop(); Console.WriteLine("the last value of the stack {0}", stack.Peek()); } }
Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0