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 型別的元素。每個節點都連結到前一個節點和後一個節點。