Linked list and Double linked list in C#
Below are two examples of implementing a linked and double linked list in C#. The framework already has a [LinkedList
The links at the bottom of the page give a whole host of discussions on the subject, mostly from stackoverflow. You might wonder where you’d ever need to use a (double) linked list, and you might be right when it comes .NET however the class itself is used internally by Regex and by a System.Net timer. It’s not (as I previously said here) used by stacktraces for Exceptions, these are are handled by the StackTrace and StackFrame classes.
But anything that needs a parent-child relationship makes use of a form of it, and a single linked list is an alternative form of a stack or queue.
As always with all the code on the site, if you spot a bug or something you think is a glaring load of rubbish, feel free to contact me on the contact page.
Doubly linked list
As you can see, the implementation for a doubly linked list doesn’t differ much from a linked list. The extra functionality comes in the form of operations like deep copying, enumerators, advanced finds and inserts which I’ve left out; these are in framework’s LinkedList