ArrayList list1 = new ArrayList();
list1.Add("a"); // 單個添加
list1.Add("b");
ArrayList list2 = new ArrayList();
list2.AddRange(new string[] { "a", "b", "c", "d" }); // 批量添加
AddRange 接受 ICollection,可一次性添加數組、List 等集合。Add,減少擴容次數。ArrayList 為非泛型集合,新代碼建議使用 List<T> 及 AddRange。List list = new List();
list.AddRange(new[] { "a", "b", "c", "d" });