Exemplo n.º 1
0
 /// <summary>
 /// Taking an element from stack
 /// </summary>
 public void Pop()
 {
     StackElement iterator = this.head;
     if (iterator == null)
     {
         throw new Exception("Stack is empty");
     }
     this.head = iterator.Next;
     Console.WriteLine(iterator.Data);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Adding element to a stack
 /// </summary>
 public void Push(int number)
 {
     StackElement tmp = new StackElement(number);
     tmp.Next = this.head;
     this.head = tmp;
 }