LinkedListT
// 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
请注意,LinkedList<T>
代表双向链表。因此,它只是节点的集合,每个节点都包含 T
类型的元素。每个节点都链接到前一个节点和后一个节点。