The Stack
Collection
The System.Collections.Stack
collection mimics the same-named memory area and works according to the LIFO (Last-In, First-Out) paradigm meaning that the last item you add to the collection is the first that is pulled out from the collection. Stack
exposes three important methods: Push
that adds an item to the collection, Pop
that allows consuming and removing an item from the collection, and Peek
that returns the top item in the collection without removing it. The following is an example:
As for Queue
, here you work with Object
items. Although this enables pushing different kinds of objects to the collection, it is not a good ...
Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.