public void push(int value) { stack_node new_node = new stack_node(value, head); head = new_node; Length++; }
public void print_stack() { stack_node temp = head; Console.Write("Head->"); while (temp != null) { Console.Write(temp.value + " "); temp = temp.next; } }
public int pop() { if (Length < 1) { throw new System.ArgumentException("Cannot pop an empty stack!"); } stack_node temp = head; head = temp.next; Length--; return(temp.value); }
public stack_node(int val, stack_node next_node) { value = val; next = next_node; }
public Stack(int first) { head = new stack_node(first); Length = 1; }