Using LinkedLists in a .NET console application Part 3 – Find and update

Let’s locate a node and add elements prior to the node.

First find the node with the string fox.

LinkedListNode<string> current = sentence.Find("fox");

Next we add quick and brown before.

sentence.AddBefore(current, "big");
sentence.AddBefore(current, "brown");

Awesome! Now iterate over the LinkedList again and check the result.

Perfect! Now go out and make some LinkedLists, it’s free!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: