Namespace: System.Collections.Generic
Stack<T>
Represents a variable size last-in-first-out (LIFO) collection of instances of the same specified type.
Properties (1)
int Count
Gets the number of elements contained in the Stack.
Value: The number of elements contained in the Stack.
Methods (3)
Stack<T>(Int32)Constructor
Initializes a new instance of the Stack class that is empty and has the specified initial capacity or the default initial capacity, whichever is greater.
| Parameter | Description |
|---|---|
| capacity | The initial number of elements that the Stack can contain. |
void Push(T)
Inserts an object at the top of the Stack.
| Parameter | Description |
|---|---|
| item | The object to push onto the Stack. The value can be null for reference types. |
T Pop
Removes and returns the object at the top of the Stack.
Returns: The object removed from the top of the Stack.