Essential C# Overview of C# collections  Suggest an edit

StackT

// Initialize a stack object of integers
var stack = new Stack<int>(); 

// add some data
stack.Push(3);
stack.Push(5);
stack.Push(8);

// elements are stored with "first in, last out" order.
// stack from top to bottom is: 8, 5, 3

// We can use peek to see the top element of the stack.
Console.WriteLine(stack.Peek()); // prints 8

// Pop removes the top element of the stack and returns it.
Console.WriteLine(stack.Pop()); // prints 8
Console.WriteLine(stack.Pop()); // prints 5
Console.WriteLine(stack.Pop()); // prints 3


Table Of Contents
22 Enum
24 Overview of C# collections
25 GUID
107 Stream
108 Timers
  ↑ ↓ to navigate     ↵ to select     Esc to close