Here is some sample code:
IList<MyType> myList1=new List<MyType>();
IList<MyType> myList2=new List<MyType>();
// Populate myList1
...
// Add contents of myList1 to myList2
myList2.Add(myList1); // Does not compile
How do I add the contents of one list to another – is there a method for this?
There’s no great built-in way to do this. Really what you want is an
AddRangemethod but it doesn’t exist on theIList<T>(or it’s hierarchy). Defining a new extension method though for this is straight forward