Name
Stack.Pop Method
Class
System.Collections.Stack
Syntax
stackvariable
.Pop( )
Return Value
Object
Description
Removes the top item from the stack and returns it as an Object
Rules at a Glance
Pop removes the top item from the stack and decrements the Count property by one.
Pop generates an error if applied to an empty stack. Thus, it’s advisable to determine when a stack is empty by using the Count property before popping the stack.
Programming Tips and Gotchas
The Peek method returns a reference to the object at the top of the stack, but unlike the Pop method, does not remove it from the stack.
See Also
Get VB.NET Language in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.