C# LINQ Concat: Syntax and Use Cases
C# LINQ Concat: Learn how to merge two sequences, understand lazy evaluation, and see practical examples with arrays and lists.

Enumerable.Concat is a LINQ extension method that combines two sequences into one lazy sequence. It returns every element from the first sequence followed by every element from the second sequence, and it does not remove duplicates. That makes it a direct choice when you need a full, unfiltered merge of two collections.
How Concat Works
The Concat method is an extension method defined in the System.Linq namespace. Its signature is straightforward:
public static IEnumerable<TSource> Concat<TSource>(this IEnumerable<TSource> first, IEnumerable<TSource> second)The method requires both sequences to be able to share the same element type TSource. If you attempt to concatenate an IEnumerable<int> with an IEnumerable<string>, the compiler rejects the call because it cannot infer a single type parameter for both inputs. This type constraint ensures that the resulting sequence has one consistent element type.
Here is a minimal example that concatenates two arrays of integers:
int[] first = { 1, 2, 3 };
int[] second = { 4, 5, 6 };
var result = first.Concat(second);
foreach (var number in result)
{
Console.WriteLine(number);
}The loop prints each number on its own line: 1, 2, 3, 4, 5, and 6. Concat does not modify the original arrays; it returns a new IEnumerable<int> that yields elements from first and then from second.
Lazy Evaluation and Deferred Execution
Concat uses deferred execution. The returned sequence does not materialize the combined data immediately. Instead, when you iterate over the result, it iterates over first completely, then over second. This is useful when the source sequences are large or come from a database query, because you avoid creating an intermediate list.
However, because evaluation is lazy, changes to the underlying collections after the Concat call are reflected when the sequence is enumerated. Consider this example:
var list1 = new List<int> { 1, 2 };
var list2 = new List<int> { 3, 4 };
var combined = list1.Concat(list2);
list1.Add(99);
foreach (var item in combined)
{
Console.WriteLine(item);
}The output includes 99 because combined is evaluated at the time of the foreach, and list1 has already been modified. This behavior can be surprising if you expect Concat to capture a snapshot of the data.
Practical Use Cases for Concat
One common use case is combining several lists into a single sequence for processing, such as when you need to aggregate data from multiple sources. For example, you might have two lists of orders from different regions and want to run a single LINQ query over both:
IEnumerable<Order> domesticOrders = GetDomesticOrders();
IEnumerable<Order> internationalOrders = GetInternationalOrders();
var allOrders = domesticOrders.Concat(internationalOrders);
var highValueOrders = allOrders.Where(o => o.Total > 1000);Because Concat is lazy, allOrders does not create a new list in memory. The Where clause operates directly over the concatenated sequence, and the overall query is executed only when you iterate over highValueOrders.
Another typical scenario is building a flat sequence from a jagged collection. If you have an array of arrays, you can use SelectMany to flatten it, but if you only have two sequences, Concat is simpler and more direct.
Concat vs. Union: Understanding the Difference
The most important distinction is that Concat preserves duplicates, while Union removes them using the default equality comparer. For example:
int[] first = { 1, 2, 3 };
int[] second = { 3, 4, 5 };
var concatResult = first.Concat(second); // 1, 2, 3, 3, 4, 5
var unionResult = first.Union(second); // 1, 2, 3, 4, 5If your goal is to merge collections without worrying about duplicate elements, Union is more appropriate. But when you need to preserve all elements, such as when concatenating log entries or event streams where order and multiplicity matter, Concat is the correct choice. Additionally, Union has higher overhead because it needs to track the elements it has already seen, whereas Concat simply yields each source element in order.
Combining Concat with Other LINQ Operators
Concat works naturally with methods like OrderBy, Select, and Where. For example, you can concatenate two sequences and then sort the result:
var sorted = first.Concat(second).OrderBy(x => x);You can also use Concat to append a single element to a sequence by wrapping it in a collection:
var numbers = new List<int> { 1, 2, 3 };
var withZero = numbers.Concat(new[] { 0 });This pattern is useful when you need to combine a sequence with a single value but do not want to modify the original collection. The resulting withZero sequence yields 1, 2, 3, 0.
Null Arguments and Error Handling
Concat throws an ArgumentNullException if either first or second is null. The null check is eager: the exception is thrown when you call Concat, before the returned sequence is iterated. If you need to handle the null case separately, check the inputs before calling the method:
if (first is null) throw new ArgumentNullException(nameof(first));
if (second is null) throw new ArgumentNullException(nameof(second));
var result = first.Concat(second);This validation does not materialize the combined data; the sequence is still evaluated lazily.
Memory and Performance Considerations
Because Concat does not allocate a new collection, its memory overhead is tied to the number of source sequences being combined, not to the number of elements. This is an advantage over using List<T>.AddRange, which copies all elements into a new list. However, iterating a concatenated sequence is slightly less efficient than iterating a single contiguous array because the Concat iterator manages two separate enumerators. In most applications the overhead is negligible, but if you concatenate many sequences in a performance-critical hot path, consider materializing the result once with ToList() and reusing it.
Concat also does not change the type of the sequence. If you concatenate two arrays, the result is still an IEnumerable<T>, not an array. If you need an array for interoperability with APIs that require T[], call ToArray() on the result.
When to Use Concat Instead of AddRange or SelectMany
There are other ways to combine collections, but Concat is often the most expressive for simple two-sequence merges. List<T>.AddRange modifies the original list and is not lazy; it immediately copies elements. SelectMany is designed for flattening nested sequences, which is a more complex operation than a simple concatenation. Use Concat when you have exactly two sequences and want to avoid mutating the sources. It is also the LINQ-idiomatic approach when you are already working with IEnumerable<T> and want to keep the query lazy.
A final advanced pattern is using Concat to add a sentinel element to a sequence. When processing a stream of numbers and you need to detect the end, you can concatenate a sentinel value:
var data = new[] { 1, 2, 3 };
var withSentinel = data.Concat(new[] { int.MaxValue });This keeps the termination logic inside a single LINQ pipeline instead of requiring a manual MoveNext() check.
Enumerable.Concat is a small but important LINQ tool. Understanding its lazy nature, duplicate-preserving behavior, and eager null checks will help you compose sequences with confidence and avoid common pitfalls.
Try matching browser tools
All toolsSmall utilities that fit C# work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related C# guides
All C# guidesC# Dispose vs Destructor: Key Differences Explained
c# dispose vs destructor: Understand the difference between Dispose and destructors in C#, when each runs, and how to manage unmanaged resources correctly.
C# Variable Declaration: Syntax and Practical Usage
Learn how to declare variables in C# with explicit types, var, and nullable annotations, and understand how defaults, scope, and readability affect your choices.
C# Primary Constructors for Classes: Syntax and Usage
Learn how to use C# primary constructors for classes: syntax, initialization, dependency injection, and limitations with practical examples.
C# IComparer: Custom Sorting with IComparer<T>
Learn how to implement IComparer<T> in C# to define custom sort order for arrays and lists, handle nulls, and avoid common performance pitfalls.
More in C#
All C# guidesThe guides filed next to this one in C#, in library order.