Using Stacks

Queues are first-in, first-out—FIFO—constructs, which is often what you need to handle time-consuming tasks that you want to handle in a first-come, first-served manner. But there are occasions when you want to reverse the order of retrieval with first-in, last-out—FILO—constructs, and in that case you use stacks. The usual example here is a spring-loaded stack of plates in cafeterias, where the first plate in the stack is the last plate taken off. You've probably heard of stacks in programming; local variables in methods are pushed onto the top of the application's internal stack to store them and popped from the top of the stack to retrieve them in reverse order. You can see the significant public properties of Stack objects in ...

Get Microsoft® Visual C#® .NET 2003 Kick Start now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.