AddRange(ICollection) Method is used to add the elements of an ICollection to the end of the ArrayList. Or in other words, this method is used to add the multiple elements from other collection into an ArrayList. Here elements are defined as the primitive or non-primitive type.
public virtual void AddRange (ICollection col);
Here, col is an ICollection whose elements should be added to the end of the ArrayList. The collection itself cannot be null, but it can contain null elements.
- If the value of col is null then this method will give ArgumentNullException.
- This method will gives NotSupportedException if the ArrayList is read-only, or the ArrayList has a fixed size
Below given are some examples to understand the implementation in a better way:
The ArrayList 1: 5 10 15 20 25 The ArrayList 2: 30 35 40 45 50 The new ArrayList is : 5 10 15 20 25 30 35 40 45 50
- C# | Adding the elements to the end of the ArrayList
- C# | Copy the elements of collection over a range of elements in ArrayList
- C# | Adding the elements of the specified collection to the end of the List
- C# | Remove all elements from the ArrayList
- C# | Sort the elements in the ArrayList
- C# | ArrayList whose elements are copies of the specified value
- C# | Get or set the number of elements that the ArrayList can contain
- C# | Getting an enumerator for a range of elements in the ArrayList
- C# | Get the number of elements actually contained in the ArrayList
- C# | Remove a range of elements from the ArrayList
- C# | Getting a subset of the elements from the source ArrayList
- C# | Copying the elements of ArrayList to a new array
- C# | Reverse the order of the elements in the entire ArrayList or in the specified range
- C# | Sets the capacity to the actual number of elements in the ArrayList
- C# | Adding the specified key and value into HybridDictionary
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.