Saturday, July 28, 2012

Beginners Dotnet Array vs ArrayList

Arrays are of fixed size.

Drawbacks:

When we add more number of values to an array than the original size of the array, arrays cannot resize themselves automatically. 

ArrayList

Array List is similar to an array, as the number of values are added to the array List. We can add, insert and delete items into an Array List very easily. 
And Array List stores any type of data inherited from System. Object. In a single Array list we can store any data type - integer, string and any type of object inherited from System. Object. 

Briefly, an array contains one data type(int) whereas array list can contain many data types(int,float,char), the data in an array is accessed by indexes. Traversing the data in the amaryllis can be done by using for. Each loop or using enumerators or using indexers. 


If you delete an item in an array, it keeps that position empty, whereas in an array list that position is occupied by the next element. 


No comments:

Post a Comment

Thank you for visiting my blog

Python -3

  Lists It is used to store Collection of data. Lists are created using square brackets: List Items Order cannot be changed. It can have dup...