在通用列表中,是否有内置函数可以从另一个列表的特定索引处添加范围,还是我必须自己编写代码?
例如:
List<int> list1 = new List<int>();
List<int> list2 = new List<int>();
list1.Add(10);
list1.Add(20);
list1.Add(30);
list2.Add(100);
//list2.AddRange(list1, 1) Add from list1 from the index 1 till the end
在这个例子中,list2 应该有三个元素:100、20 和 30。
我需要自己编写代码还是有内置的函数可以做到这一点?
AddRange()
方法了。 - DGibbs