public object Add(int index, object o) { if (index < 0) throw new ArgumentOutOfRangeException("Index: " + index); if (index > count) index = count; Node current = head; if(this.Empty || index == 0) { head = new Node(o, head); } else { for (int i = 0; i < index - 1; i++) current = current.Next; current.Next = new Node(o, current.Next); } count++; return o; }
public Linkedlist() { head = null; count = 0; }
public Node(object data, Node next) { this.data = data; this.next = next; }