public Link Delete(int key) { Link current = first; Link previous = first; while (current.Data != key) { if (current.Next == null) { return null; } previous = current; current = current.Next; } if (current == first) { first = first.Next; } else { previous.Next = current.Next; } return current; }
public Link DeleteFirst() { Link temp = first; first = first.Next; return temp; }
public void InsertFirst(int data) { var newLink = new Link {Data = data, Next = first}; first = newLink; }
public LinkedList() { first = null; }