Remove(LinkedListNode<T>) method is used to remove the specified node from the LinkedList<
T>.
Syntax:
public void Remove (System.Collections.Generic.LinkedListNode<T> node);
Here,
node is the LinkedListNode<
T> to remove from the LinkedList<
T>.
Exceptions:
- ArgumentNullException : If the node is null.
- InvalidOperationException : If the node is not in the current LinkedList<T>.
Below given are some examples to understand the implementation in a better way:
Example 1:
Output:
Total nodes in myList are : 4
2
4
6
8
Total nodes in myList are : 3
4
6
8
Example 2: