Using LinkedLists in a .NET console application Part 2 – Add and remove nodes

Now it’s time to add a new word to the beginning of the list.

sentence.AddFirst("today");

If you iterate over the list again you will see that today is added as the first element in the linked list.

Now let’s create a LinkedListnode containing the node we just created, remove it from the beginning and add it last.

In the next post we’ll search the node and add elements to it.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: