以下是引用片段:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace Example9_17 { class Program { static void Main(string[] args) { ArrayList myArrayList = new ArrayList(3);
myArrayList.Add("Hello "); myArrayList.Add("World!"); Console.WriteLine(myArrayList[0]);
//输出myArrayList的容量和元素个数。 Console.WriteLine("Capacity: {0}", myArrayList.Capacity); Console.WriteLine("Count: {0}", myArrayList.Count);
//删除索引值为0的元素,即:“Hello ” myArrayList.RemoveAt(0); Console.WriteLine("After Cleared"); Console.WriteLine(myArrayList[0]);
//输出myArrayList的容量和元素个数。 Console.WriteLine("Capacity: {0}", myArrayList.Capacity); Console.WriteLine("Count: {0}", myArrayList.Count);
Console.ReadLine(); } } }
|