mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00] 1.0.5000.0 2.0.0.0 4.0.0.0 System.Object System.Collections.ICollection System.ICloneable System.Diagnostics.DebuggerDisplay("Count={Count}") System.Diagnostics.DebuggerTypeProxy(typeof(System.Collections.CollectionDebuggerView)) System.Runtime.InteropServices.ComVisible(true)

For the generic version of this collection, see .

is implemented as a circular buffer.

The capacity of a is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation.

If is less than the capacity of the stack, is an O(1) operation. If the capacity needs to be increased to accommodate the new element, becomes an O() operation, where is . is an O(1) operation.

accepts null as a valid value and allows duplicate elements.

Represents a simple last-in-first-out (LIFO) non-generic collection of objects.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The capacity of a is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array.

  If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the .

  This constructor is an O(1) operation.

  Initializes a new instance of the class that is empty and has the default initial capacity.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The capacity of a is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array.

  If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the .

  The elements are copied onto the in the same order they are read by the of the .

  This constructor is an O() operation, where is the number of elements in .

  Initializes a new instance of the class that contains elements copied from the specified collection and has the same initial capacity as the number of elements copied.

  The to copy elements from.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The capacity of a is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array.

  If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the .

  This constructor is an O() operation, where is .

  Initializes a new instance of the class that is empty and has the specified initial capacity or the default initial capacity, whichever is greater.

  The initial number of elements that the can contain.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void

  is set to zero, and references to other objects from elements of the collection are also released.

  This method is an O() operation, where is .

  Removes all objects from the .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object

  A shallow copy of a collection copies only the elements of the collection, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new collection point to the same objects that the references in the original collection point to.

  In contrast, a deep copy of a collection copies the elements and everything directly or indirectly referenced by the elements.

  This method is an O() operation, where is .

  Creates a shallow copy of the .

  A shallow copy of the .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  This method determines equality by calling .

  This method performs a linear search; therefore, this method is an O() operation, where is .

  Starting with the .NET Framework 2.0, this method uses the collection’s objects’ and methods on to determine whether exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the parameter on the objects in the collection.

  Determines whether an element is in the .

  true, if is found in the ; otherwise, false.

  The to locate in the . The value can be null.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  The elements are copied onto the array in last-in-first-out (LIFO) order, similar to the order of the elements returned by a succession of calls to .

  This method is an O() operation, where is .

  Copies the to an existing one-dimensional , starting at the specified array index.

  The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. The zero-based index in at which copying begins.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 To be added: an object of type 'int'

  The capacity is the number of elements that the can store. is the number of elements that are actually in the .

  The capacity is always greater than or equal to . If exceeds the capacity while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements.

  Retrieving the value of this property is an O(1) operation.

  Gets the number of elements contained in the .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.IEnumerator

  [Visual Basic, C#]

  The foreach statement of the C# language (for each in Visual Basic) hides the complexity of the enumerators. Therefore, using foreach is recommended, instead of directly manipulating the enumerator.

  Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection.

  Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of .

  returns the same object until either or is called. sets to the next element.

  If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns false. When the enumerator is at this position, subsequent calls to also return false. If the last call to returned false, is undefined. To set to the first element of the collection again, you can call followed by .

  An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined.

  The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

  This method is an O(1) operation.

  Returns an for the .

  An for the .

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean To be added: an object of type 'bool'

  To guarantee the thread safety of the , all operations must be done through the wrapper returned by the method.

  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.

  The following code example shows how to lock the collection using the during the entire enumeration.

  code reference: Classic Stack.IsSynchronized Example#2

  Retrieving the value of this property is an O(1) operation.

  Gets a value indicating whether access to the is synchronized (thread safe).

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object

  This method is similar to the method, but does not modify the .

  null can be pushed onto the as a placeholder, if needed. To distinguish between a null value and the end of the stack, check the property or catch the , which is thrown when the is empty.

  This method is an O(1) operation.

  Returns the object at the top of the without removing it.

  The at the top of the .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object

  This method is similar to the method, but does not modify the .

  null can be pushed onto the as a placeholder, if needed. To distinguish between a null value and the end of the stack, check the property or catch the , which is thrown when the is empty.

  is implemented as a circular buffer. This method is an O(1) operation.

  Removes and returns the object at the top of the .

  The removed from the top of the .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  is implemented as a circular buffer.

  If already equals the capacity, the capacity of the is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added.

  null can be pushed onto the as a placeholder, if needed. It occupies a slot in the stack and is treated like any object.

  If is less than the capacity of the stack, is an O(1) operation. If the capacity needs to be increased to accommodate the new element, becomes an O() operation, where is .

  Inserts an object at the top of the .

  The to push onto the . The value can be null.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.Stack ``

  To guarantee the thread safety of the , all operations must be done through this wrapper.

  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.

  The following code example shows how to lock the collection using the during the entire enumeration.

  code reference: Classic Stack.IsSynchronized Example#2

  This method is an O(1) operation.

  Returns a synchronized (thread safe) wrapper for the .

  A synchronized wrapper around the .

  The to synchronize.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object To be added: an object of type 'object'

  To create a synchronized version of the , use the method. However, derived classes can provide their own synchronized version of the using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object.

  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.

  The following code example shows how to lock the collection using the during the entire enumeration.

  code reference: Classic Stack.IsSynchronized Example#2

  Retrieving the value of this property is an O(1) operation.

  Gets an object that can be used to synchronize access to the .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object[]

  The elements are copied onto the array in last-in-first-out (LIFO) order, similar to the order of the elements returned by a succession of calls to .

  This method is an O() operation, where is .

  Copies the to a new array.

  A new array containing copies of the elements of the .