Table of Contents

Class Stack

Namespace
System.Collections
Assembly
nanoFramework.System.Collections.dll

An array implementation of a stack. Push can be O(n). Pop is O(1).

public class Stack : ICollection, IEnumerable, ICloneable
Inheritance
Stack
Implements
Inherited Members
Extension Methods

Constructors

Stack()

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

public Stack()

Properties

Count

Size of the stack

public virtual int Count { get; }

Property Value

int

IsSynchronized

Returns whether the current stack is synchornized. Always return false.

public virtual bool IsSynchronized { get; }

Property Value

bool

SyncRoot

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

public virtual object SyncRoot { get; }

Property Value

object

Methods

Clear()

Removes all Objects from the Stack.

public virtual void Clear()

Clone()

Creates a shallow copy of the Stack.

public virtual object Clone()

Returns

object

A shallow copy of the Stack.

Contains(object)

Determines whether an element is in the Stack.

public virtual bool Contains(object obj)

Parameters

obj object

The Object to locate in the Stack.

Returns

bool

true, if obj is found in the Stack; otherwise, false

CopyTo(Array, int)

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

public virtual void CopyTo(Array array, int index)

Parameters

array Array

The one-dimensional Array that is the destination of the elements copied from Stack.

index int

The zero-based index in array at which copying begins.

GetEnumerator()

Returns an IEnumerator for this Stack.

public virtual IEnumerator GetEnumerator()

Returns

IEnumerator

An IEnumerator for the Stack.

Peek()

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

public virtual object Peek()

Returns

object

The Object at the top of the Stack.

Pop()

Removes and returns the object at the top of the Stack.

public virtual object Pop()

Returns

object

The Object removed from the top of the Stack.

Push(object)

Inserts an object at the top of the Stack.

public virtual void Push(object obj)

Parameters

obj object

The Object to push onto the Stack.

ToArray()

Copies the Stack to a new array, in the same order Pop would return the items.

public virtual object[] ToArray()

Returns

object[]

A new array containing copies of the elements of the Stack.