private bool check()
        {
            if (this.N == 0)
            {
                if (this.first != null)
                {
                    return(false);
                }
            }
            else if (this.N == 1)
            {
                if (this.first == null)
                {
                    return(false);
                }
                if (this.first.next != null)
                {
                    return(false);
                }
            }
            else if (this.first.next == null)
            {
                return(false);
            }

            int num = 0;

            for (LinkedStack.Node node = this.first; node != null; node = node.next)
            {
                num++;
            }
            return(num == this.N);
        }
        public void Push(object obj)
        {
            // save a link to the list
            LinkedStack.Node node = this.first;
            // create a new node for the beginning
            this.first = new Node(this, null);
            //  set value
            this.first.item = obj;
            // set next link
            this.first.next = node;

            this.N++;
            ArgumentOutOfRangeException();
        }
        public object Pop()
        {
            if (IsEmpty)
            {
                throw new NotSupportedException("Stack underflow");
            }
            // save current 1st value
            object result = this.first.item;

            // update first to former second
            this.first = this.first.next;
            // decrease count
            this.N--;
            ArgumentOutOfRangeException();
            return(result);
        }
 internal Node(LinkedStack linkedStack, Node next)
 {
     parent    = linkedStack;
     item      = null;
     this.next = next;
 }
 internal static object GetNodeObject(LinkedStack.Node node)
 {
     return(node.item);
 }
 public void Reset()
 {
     current = parentStack.first;
 }
 internal ListIterator(LinkedStack linkedStack)
 {
     this.parentStack = linkedStack;
     this.current     = linkedStack.first;
 }
 public LinkedStack()
 {
     this.first = null;
     this.N     = 0;
     ArgumentOutOfRangeException();
 }