ArrayList AddRange() method in C# – Programming Code Examples
C# C# Console Application

ArrayList AddRange() method in C#1 min read

.Net framework ArrayList AddRange() method allow us to add the elements of an ICollection to the end of the ArrayList. this arraylist AddRange() method exists under System.Collections namespace.

this method require to pass a parameter named ‘c’. the ‘c’ parameter type is System.Collections.ICollection, which represents 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.




the AddRange() method throw ArgumentNullException exception, if the ‘c’ is null. this method also throw NotSupportedException, if the ArrayList is read-only or the ArrayList has a fixed size. arraylist accepts duplicate values.

the following console c# example code demonstrate us how can we add a collection of elements to the end of an arraylist programmatically at run time in an console application.

C# Code:

 

Output:

 

Leave a Comment