C# Stack Stack(ICollection)

Description

Stack Stack(ICollection) initializes a new instance of the Stack class that contains elements copied from the specified collection and has the same initial capacity as the number of elements copied.

Syntax

Stack.Stack(ICollection) has the following syntax.


public Stack(
  ICollection col
)

Parameters

Stack.Stack(ICollection) has the following parameters.

  • col - The ICollection to copy elements from.

Example


using System;//from w w  w  . j  a v a 2s . c  o m
using System.Collections;
public class SamplesStack  {

   public static void Main()  {
      Stack myStack = new Stack();
      myStack.Push( "1" );

      Stack myStack1 = new Stack(myStack);

   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack