System.Collections.Stack Class

Represents a simple last-in-first-out (LIFO) non-generic collection of objects.

See Also: Stack Members


public class Stack : ICollection, ICloneable


For the generic version of this collection, see Stack`1.

Stack is implemented as a circular buffer.

The capacity of a Stack is the number of elements the Stack can hold. As elements are added to a Stack, the capacity is automatically increased as required through reallocation.

If Stack.Count is less than the capacity of the stack, Stack.Push(object) is an O(1) operation. If the capacity needs to be increased to accommodate the new element, Stack.Push(object) becomes an O(n) operation, where n is Stack.Count. Stack.Pop is an O(1) operation.

Stack accepts null as a valid value and allows duplicate elements.


Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0,,