Represents a simple last-in-first-out (LIFO) non-generic collection of objects.
Assembly: mscorlib (in mscorlib.dll)
Initializes a new instance of theclass that is empty and has the default initial capacity.
Initializes a new instance of theclass that contains elements copied from the specified collection and has the same initial capacity as the number of elements copied.
Initializes a new instance of theclass that is empty and has the specified initial capacity or the default initial capacity, whichever is greater.
Removes all objects from the.
Creates a shallow copy of the.
Determines whether an element is in the.
Copies the Array, starting at the specified array index.to an existing one-dimensional
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)
Returns an IEnumerator for the .
Serves as the default hash function. (Inherited from Object.)
Returns the object at the top of thewithout removing it.
Removes and returns the object at the top of the.
Inserts an object at the top of the.
Returns a synchronized (thread safe) wrapper for the.
Copies theto a new array.
Returns a string that represents the current object.(Inherited from Object.)
Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)
For the generic version of this collection, see System.Collections.Generic.Stack<'T>.
The capacity of ais the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation.
If Count is less than the capacity of the stack, Push is an O(1) operation. If the capacity needs to be increased to accommodate the new element, Push becomes an O(n) operation, where n is Count. Pop is an O(1) operation.
accepts null as a valid value and allows duplicate elements.
Available since 10
Available since 1.1
Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
To guarantee the thread safety of the Synchronized method., all operations must be done through the wrapper returned by the
Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.