C Sharp Programming/The .NET Framework/Collections

Lists
A list is a dynamic array that resizes itself as needed, if more data is inserted than it can hold at the time of insertion. Items can be inserted at any index, deleted at any index and accessed at any index. The C# non-generic list class is the, while the generic one is.

Many of the class' methods and properties are demonstrated in the following example:

The terminal output is:

List demo | bread | butter | chocolate | roast beef | tomato | vanilla cake | yoghurt | The list now has 0 items.

LinkedLists
Items in a linked list can be accessed directly only one after the other. Of course an item at any index can be accessed, but the list must iterate to the item from the first one, which is much slower than accessing items by index in an array or a list. There is no non-generic linked list in C#, while the generic one is.

Queues
A queue is a FIFO (first in - first out) collection. The item first pushed in the queue gets taken first with the pop function. Only the first item is accessible at any time, and items can only be put to the end. The non-generic queue class is called Queue, while the generic one is.

Stacks
A stack is a LIFO (last in - first out) collection. The item pushed in first will be the last to be taken by pop. Only the last item is accessible at any time, and items can only be put at the top. The non-generic stack class is Stack, while the generic one is.

Hashtables and dictionaries
A dictionary is a collection of values with keys. The values can be very complex, yet searching the keys is still fast. The non-generic class is, while the generic one is.