public object Add(int index, object o)
        {
            if (index < 0)
                throw new ArgumentOutOfRangeException("index: " + index);

            if (index > count)
                index = count;

            Node current = this.head;

            if (this.Empty || index == 0)
            {
                this.head = new Node(o, this.head);
            }
            else
            {
                for (int i = 0; i < index - 1; i++)
                    current = current.Next;

                current.Next = new Node(o, current.Next);

            }

            count++;

            return o;
        }
        public object Remove(int index)
        {
            if (index < 0)
                throw new ArgumentOutOfRangeException("index: "+index);

            if (this.Empty)
                return null;

            if (index > this.count)
                index = count - 1;

            Node current = this.head;
            object result = null;

            if (index == 0)
            {
                result = current.Data;
                this.head = current.Next;

            }
            else
            {
                for (int i = 0; i < index - 1; i++)
                    current = current.Next;

                result = current.Next.Data;

                current.Next = current.Next.Next;      //skips the reference to "deleted" node

            }
            count++;

            return result;
        }
 public void Clear()
 {
     this.head = null;
     this.count = 0;
 }
 public LinkedList()
 {
     this.head = null;
     this.count = 0;
 }
 public Node(object data, Node next)
 {
     this.data = data;
     this.next = next;
 }