C# C# Console Application

How to add an item to the ArrayList in C#1 min read

.Net framework ArrayList Add() method allow us to add an object to the end of the ArrayList. this arraylist Add() method exists in System.Collections namespace. the Add() method require to pass a parameter named ‘value’.

this ‘value’ parameter value type is System.Object which represents the Object to be added to the end of the arraylist. this value can be null. the Add() method return value type is System.Int32. this integer return value represents the arraylist index at which the ‘value’ has been added.

this method implements as IList.Add(Object). arralist Add() method throw NoSupportedException exception, if the arraylist is read-only or the arraylist has a fixed size. arraylist accept null as a valid value and it also allow duplicate elements. arraylist Capacity increased automatically by reallocating the internal array.

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

C# Code:




Leave a Comment