Create a Stack with specified initial capacity in CSharp
Description
The following code shows how to create a Stack with specified initial capacity.
Example
using System;// w w w . j a v a 2s . c o m
using System.Collections.Generic;
class Example
{
public static void Main()
{
Stack<string> numbers = new Stack<string>(10);
numbers.Push("one");
numbers.Push("two");
numbers.Push("three");
numbers.Push("four");
numbers.Push("five");
foreach( string number in numbers )
{
Console.WriteLine(number);
}
}
}
The code above generates the following result.