Posts

Showing posts with the label #C# #ArrayList

C# - ArrayList

In C#, the ArrayList is a non-generic collection of objects whose size increases dynamically. It is the same as Array except that its size increases dynamically. An ArrayList can be used to add unknown data where you don't know the types and the size of the data. Create an ArrayList -  The ArrayList class included in the System.Collections namespace. Create object of the ArrayList using the new keyword. Example: Create an ArrayList using System.Collections; ArrayList arlist = new ArrayList (); // or var arlist = new ArrayList (); // recommended Adding Elements in ArrayList Use the  Add()  method or  object initializer syntax  to add elements in an  ArrayList . An  ArrayList  can contain multiple  null  and duplicate values. Example: Adding Elements in ArrayList // adding elements using ArrayList.Add() method var arlist1 = new ArrayList (); arlist1.Add(1); arlist1.Add( "Bill" ); arlist1.Add( " " ); arlist1.Add(true); arlist1.Ad...