Merge 2 lists in C#
To merger 2 lists in C# you can use theLINQ
Concat
and ToList
.Example
using System;
using System.Collections.Generic;
using System.Linq;
public class Client
{
public static void Main()
{
List<string> list1 = new List<string>(new string[] { "1", "2", "3" });
List<string> list2 = new List<string>(new string[] { "4", "5", "6" });
list1 = list1.Concat(list2).ToList();
Console.WriteLine(list1.Count());
}
}
Output
6