Clear a stack : Stack « Data Structure « C# / CSharp Tutorial






using System;
using System.Collections;

class MainClass
{
  static void Main(string[] args)
  {
    Stack a = new Stack(10);
    int x = 0;

    a.Push(x);
    x++;
    a.Push(x);
    foreach (int y in a)
    {
      Console.WriteLine(y);
    }

    a.Pop();
    a.Clear();
  }
}
1
0








11.39.Stack
11.39.1.Push and pop value
11.39.2.Clear a stack
11.39.3.Pop and Peek
11.39.4.Stack And Queue
11.39.5.Stack and Queue are both ICollection