Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add List<T> to beginning of another List<T>

I'm looking for a way to add a List to the beginning of another List (specifically, strings).

I have found the List.Insert method, but that is for a single object.

I have thought about a for each loop to insert the item, but that would add them backwards.

How can I do this?

Thanks.

like image 785
user3397642 Avatar asked Mar 10 '14 20:03

user3397642


1 Answers

You can use List.InsertRange:

list.InsertRange(0, otherStrings);
like image 130
Tim Schmelter Avatar answered Sep 24 '22 08:09

Tim Schmelter