Let's say I have the following:
LinkedList<int> list1 = new LinkedList<int>();
LinkedList<int> list2 = new LinkedList<int>();
list1.AddLast(1);
list1.AddLast(2);
list2.AddLast(1);
list2.AddLast(2);
As far as I know you cannot do the following;
list1.AddLast(list2.First);
and except the lists to be connected together.
What is the proper way to merge two LinkedLists in C#? I know there is a Union()
method, but it seems like such strong point of LinkedList in C++ is that you can easily combine and break lists apart if need be.
The LinkedList class does not support chaining, splitting, cycles, or other features that can leave the list in an inconsistent state.