///Sets next element from the Last Last, returns element of the former Last. public int Pop() { if (Last == null) { return(0); } int result = Last.GetValue(); Last = Last.GetNext(); return(result); }
/// Deletes last element, returns its value. If stack is empty, throws exeption. public int Pop() { if (head == null) { throw new StackNullExeption("Trying to pop an empty stack."); } int result = head.GetValue(); head = head.GetNext(); return(result); }