Stack Tutorial In C# | ||
| ||
| stack is a LIFO (Last In First Out) queue, so if you add two items and then ask for an item you would get the second item then the first item. To add items to the Stack you use Push method. This method takes an object of any type but to keep things simple lets just give it a string object: Viewing a Single Object Without Removing it From the Stack You can use the Peak method to get the bottom-most object in the Stack without removing it from the Stack:
You can read any of the data in the Stack by using an enumerator:
To pop an item from the Stack you can use the Pop statement. This returns the bottom-most object of the stack.
| ||
| | ||
| |