C# Stack Pop
Description
Removes and returns the object at the top of the Stack.
Syntax
public T Pop()
Returns
Returns The object removed from the top of the Stack.
Example
using System;//from w ww . j ava2 s. c o m
using System.Collections.Generic;
class Example
{
public static void Main()
{
Stack<string> numbers = new Stack<string>();
numbers.Push("one");
numbers.Push("two");
numbers.Push("three");
numbers.Push("four");
numbers.Push("five");
Console.WriteLine(numbers.Pop());
Console.WriteLine(numbers.Peek());
Console.WriteLine(numbers.Pop());
}
}
The code above generates the following result.