ArrayList.AddRange(ICollection) Method is used to add the elements of an ICollection to the end of the ArrayList.
public virtual void AddRange (System.Collections.ICollection c);
Here, c is the ICollection whose elements should be added to the end of the ArrayList. The collection itself cannot be null, but it can contain elements that are null.
- ArgumentException: If c is null
- NotSupportedException: If the ArrayList is read-only or ArrayList has a fixed size.
Below programs illustrate the use of the above-discussed method:
Before AddRange Method A B C D E F After AddRange Method A B C D E F A B C D E F
Before AddRange Method Geeks GFG C# Tutorials After AddRange Method Geeks GFG C# Tutorials Collections Generic List
- ArrayList accepts null as a valid value and allows duplicate elements.
- The order of the elements in the ICollection is preserved in the ArrayList.
- C# | Adding elements to the end of the ArrayList
- C# | Adding the elements of the specified collection to the end of the List
- C# | Add an object to the end of the ArrayList
- C# | Copy the elements of collection over a range of elements in ArrayList
- C# | Adding new node or value at the end of LinkedList<T>
- C# | Get the number of elements actually contained in the ArrayList
- C# | Copying the elements of ArrayList to a new array
- C# | Get or set the number of elements that the ArrayList can contain
- C# | Remove a range of elements from the ArrayList
- C# | Remove all elements from the ArrayList
- C# | Reverse the order of the elements in the entire ArrayList or in the specified range
- C# | ArrayList whose elements are copies of the specified value
- C# | Sort the elements in the ArrayList
- C# | Sets the capacity to the actual number of elements in the ArrayList
- C# | Getting an enumerator for a range of elements in the ArrayList
- C# | Getting a subset of the elements from the source ArrayList
- C# | Remove the first occurrence of a specific object from the ArrayList
- C# | Check whether an element is contained in the ArrayList
- C# | Check if the ArrayList is read-only
- C# | Insert an element into the ArrayList at the specified index
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.