// initialize a LinkedList of integers
LinkedList list = new LinkedList<int>();
// add some numbers to our list.
list.AddLast(3);
list.AddLast(5);
list.AddLast(8);
// the list currently is 3, 5, 8
list.AddFirst(2);
// the list now is 2, 3, 5, 8
list.RemoveFirst();
// the list is now 3, 5, 8
list.RemoveLast();
// the list is now 3, 5
Note that LinkedList<T>
represents the doubly linked list. So, it's simply collection of nodes and each node contains an element of type T
. Each node is linked to the preceding node and the following node.