Reputation: 16622
List<string> list1 = new List<string>();
list1.Add("Blah");
list1.Add("Bleh");
list1.Add("Blih");
List<string> list2 = new List<string>();
list2.Add("Ooga");
list2.Add("Booga");
list2.Add("Wooga");
Is there a method to create a third list that has {"Blah", "Bleh", "Blih", "Ooga", "Booga", "Wooga"}
or, alternatively, change list1
so it has the three additional elements in list2?
Upvotes: 1
Views: 1224
Reputation: 26632
With LINQ, you can do:
List<string> list1 = new List<string>();
list1.Add("Blah");
list1.Add("Bleh");
list1.Add("Blih");
List<string> list2 = new List<string>();
list2.Add("Ooga");
list2.Add("Booga");
list2.Add("Wooga");
var finalList = list1.Concat( list2 ).ToList();
Upvotes: 8