C# | Adding elements to the end of the ArrayList
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