O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required