C# Stack TrimExcess
Description
Set the capacity to the actual number of elements in the Stack, if that number is less than 90 percent of current capacity.
Syntax
public void TrimExcess()
Example
using System;/*from w ww .j a v a 2 s . c o m*/
using System.Collections.Generic;
class Example
{
public static void Main()
{
Stack<string> numbers = new Stack<string>();
numbers.Push("one");
numbers.Push("two");
numbers.Push("three");
numbers.Push("four");
numbers.Push("five");
numbers.TrimExcess();
}
}