LinkedList<T>
suggest change// initialize a LinkedList of integers
LinkedList<int> 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 is simply a collection of nodes, and each node contains an element of type T. Each node is linked to the preceding node and the following node.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents