LinkedList(Of T)
CollectionThink of the System.Collections.Generic.LinkedList(Of T)
collection as a chain in which each ring is an item in the collection that is linked to the others. In other words, an item is linked to the previous one and the next one and points to them. Each item in the collection is considered as a LinkedListNode(Of T)
, so if you decide to create a LinkedList(Of Person)
, each Person
instance will be represented by a LinkedListNode(Of Person)
. Table 16.2 summarizes the most common methods and properties for the collection over the ones that you already know (derived from IList(Of T)
).
The following code provides an example of creating and consuming a LinkedList(Of Person)
collection (see comments for explanations):
The most important difference between this collection and the other ones is that items are linked. This is demonstrated by an Enumerator
structure exposed by every instance of the collection that enables moving between items, as demonstrated in the following code snippet:
This code basically demonstrates that items in the collections are linked and that each one points to the next one.
3.135.239.111