/// <summary>Removes the specified node from the <see cref="T:System.Collections.Generic.LinkedList`1" />.</summary> /// <param name="node">The <see cref="T:System.Collections.Generic.LinkedListNode`1" /> to remove from the <see cref="T:System.Collections.Generic.LinkedList`1" />.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="node" /> is null.</exception> /// <exception cref="T:System.InvalidOperationException"> /// <paramref name="node" /> is not in the current <see cref="T:System.Collections.Generic.LinkedList`1" />.</exception> public void Remove(LinkedListNode <T> node) { VerifyReferencedNode(node); count--; if (count == 0) { first = null; } if (node == first) { first = first.forward; } version++; node.Detach(); }
/// <summary>Removes the specified node from the <see cref="T:System.Collections.Generic.LinkedList`1" />.</summary> /// <param name="node">The <see cref="T:System.Collections.Generic.LinkedListNode`1" /> to remove from the <see cref="T:System.Collections.Generic.LinkedList`1" />.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="node" /> is null.</exception> /// <exception cref="T:System.InvalidOperationException"> /// <paramref name="node" /> is not in the current <see cref="T:System.Collections.Generic.LinkedList`1" />.</exception> public void Remove(LinkedListNode <T> node) { this.VerifyReferencedNode(node); this.count -= 1u; if (this.count == 0u) { this.first = null; } if (node == this.first) { this.first = this.first.forward; } this.version += 1u; node.Detach(); }