1

I have two list defined as

List<List<int>> thirdLevel = new List<List<int>>();
List<List<int>> fourthLevel = new List<List<int>>();

Here the type of both the list are same. I want to add contents of 1 list to other. Just want to make a duplicate of that list. I am unable to add 1 list in other.

I tried using:

thirdLevel.Add(fourthLevel);

But I am getting error only.The error states that the overloaded method of Add(int) has some invalid arguments. I don't know what should I try. Can't I add a list in this way?

Can you just guide me, how should I add One list to other, if I have defined the list inside a list.

4

1 回答 1

2

Sound like you need AddRange instead of Add if you add a list of items into another list:

 thirdLevel.AddRange(fourthLevel); 
于 2013-03-31T02:40:14.683 回答