int[] numbers = { 1, 2, 3, 4 }; ArrayList arrayList = new ArrayList(); arrayList.AddAll(numbers);
ListIn this example, a list of strings is created and then added to an ArrayList using AddAll method. The package library for the ArrayList class is System.Collections.names = new List { "Alice", "Bob", "Charlie" }; ArrayList arrayList = new ArrayList(); arrayList.AddAll(names);