System.Collections.Stack.Pop Method

Removes and returns the object at the top of the Stack.

Syntax

public virtual object Pop ()

Returns

The object removed from the top of the Stack.

Remarks

This method is similar to the Stack.Peek method, but Stack.Peek does not modify the Stack.

null can be pushed onto the Stack as a placeholder, if needed. To distinguish between a null value and the end of the stack, check the Stack.Count property or catch the InvalidOperationException, which is thrown when the Stack is empty.

Stack is implemented as a circular buffer. This method is an O(1) operation.

Requirements

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