Exemple #1
0
 public T Pop()
 {
     if (first != null)
     {
         T temp = first.value;
         first = first.nextElement;
         return(temp);
     }
     else
     {
         throw new NullReferenceException();
     }
 }
Exemple #2
0
 public void Push(T element)
 {
     if (first != null)
     {
         StackElement <T> temp = new StackElement <T>()
         {
             value = element, nextElement = first
         };
         first = temp;
     }
     else
     {
         first = new StackElement <T>()
         {
             value       = element,
             nextElement = null
         };
     }
 }