// Add element to stack public void Push(T value) { var element = new SimpleStackElement <T>(value); element.Next = Head; Head = element; }
// Delete element from stack public T Pop() { if (Head == null) { throw new Exception("Stack is empty"); } var returnElement = Head; Head = Head.Next; return(returnElement.Value); }
} // initializing top stack element public SimpleStack() // stack constructor { Head = null; }