This post will discuss how to join two lists in C#. The solution should contain all elements of the first list, followed by all elements of the second list.

1. Using Enumerable.Concat() method

The Enumerable.Concat() method provides a simple way to join multiple lists in C#. The following example demonstrates the usage of the Concat() method by joining two lists.

Download  Run Code

2. Using AddRange() method

f you need to merge the second list into the first list, use the AddRange() method to add all elements of the second list at the end of the first list. Here’s what the code would look like:

Download  Run Code

3. Using List<T>.ForEach(Action<T>) method

To merge the second list elements into the first list, we can also use the foreach statement to individually copy each element of the second list to the first list.

Download  Run Code

That’s all about joining two lists in C#.