NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Stack.Pop

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

[Visual Basic]
Overridable Public Function Pop() As Object
[C#]
public virtual object Pop();
[C++]
public: virtual Object* Pop();
[JScript]
public function Pop() : Object;

Return Value

The Object removed from the top of the Stack.

Exceptions

Exception Type Condition
InvalidOperationException The Stack has no elements.

Remarks

This method can be overridden by a derived class.

Stack is implemented as a circular buffer. Push is an O(n) operation; Pop is an O(1) operation.

a null reference (in Visual Basic Nothing) 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 Count property or catch theInvalidOperationException, which is thrown when the Stack is empty.

Example

The following example shows a null value inserted into a stack and then retrieved.

Stack s = new Stack ();
     s.Push ("Red");
     s.Push ("Green");
     s.Push (null);
     s.Push ("Blue");
     s.Push ("Green");
     String sc;
     while (s.Count > 0)
     {
         sc = (string) s.Pop();
         Console.WriteLine (sc);
     }

See Also

Stack Class | Stack Members | System.Collections Namespace | Peek | Push