C# ArrayList中的insertrange方法示例
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { ArrayList counting = new ArrayList(); counting.Add("one"); counting.Add("two"); counting.Add("three"); counting.Add("four"); counting.Add("five"); counting.Add("six"); counting.Add("seven"); Stack numbers = new Stack(); numbers.Push(1); numbers.Push(2); numbers.Push(3); numbers.Push(4); Console.WriteLine("The number of elements in the arraylist are:"); foreach (object i in counting) { Console.WriteLine(i); } counting.InsertRange(7, numbers); Console.WriteLine("The elemets after the insertrange operation are:"); foreach (object i in counting) { Console.WriteLine(i); } } } }
insertrange方法将集合的元素插入到ArrayList中指定索引处。
日期:2020-04-11 23:03:41 来源:oir作者:oir