How to Merge Two Lists

You can merge two lists in C# using several methods. The Concat() method from LINQ is a popular choice for its readability. It appends one list to another and returns a new IEnumerable collection, which you can then convert back to a List using ToList().

C# Example Code
using System;
using System.Collections.Generic;
using System.Linq;

public class MergeLists
{
    public static void Main(string[] args)
    {
        var listA = new List<string> { "apple", "banana" };
        var listB = new List<string> { "cherry", "date" };

        // Using LINQ Concat()
        var mergedList = listA.Concat(listB).ToList();

        Console.WriteLine("Merged List:");
        foreach (var item in mergedList)
        {
            Console.WriteLine(item);
        }
    }
}