C# Stack Pop

Description

Stack Pop removes and returns the object at the top of the Stack.

Syntax

Stack.Pop has the following syntax.


public virtual Object Pop()

Returns

Stack.Pop method returns The Object removed from the top of the Stack.

Example

The following example shows how to add elements to the Stack, remove elements from the Stack.


/*from   www  .  ja  v  a 2  s . c o  m*/
using System;
 using System.Collections;
 public class SamplesStack  {

    public static void Main()  {

       Stack myStack = new Stack();
       myStack.Push( "A" );
       myStack.Push( "B" );
       myStack.Push( "C" );

       Console.WriteLine(myStack.Pop() );

    }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack