C# C# Console Application

How to remove all items from an ArrayList in C#1 min read

.Net framework ArrayList.Clear() method allow us to remove all elements from the ArrayList. this arraylist Clear() method exists under System.Collections namespace. this method has no required or optional parameter. the Clear() method implements as IList.Clear().

the arraylist Clear() method throw NotSupportedException exception, if the arraylist is read-only or the arraylist has a fixed size. this method set the Count is zero and references to other objects from elements of the collection are also released. but the Capacity remain unchanged in arraylist.




the following console c# example code demonstrate us how can we remove all elements from the arraylist programmatically at run time in an console  application.

C# Code:

 

Output:

 

Leave a Comment