Array (A System namespace) is a datatype, that can be used by calling indexes. during runtime, one cannot really change the size of the array, unless you use the method of copying the array and getting rid of the old one.
In .NET, the Visual Studio makes use of a special class to store the data. Because of this, the performance is actually quite fast. This is also because in an array, you need to specify the size and thus, the data is stored one after the other.
int myNumbers=newint; myNumbers=16;
ArrayList (System.Collections namespace) is a datatype collection. In order to fill an ArrayList, one can use the .Add property. ArrayLists are very dynamic in the sense that when you add and/or remove items from it, the performace stays the same.
The internal structure of an ArrayList is an array.
ArrayList myArray =newArrayList(); myArray.Add(“Steph”);string str = myArray;
Most of the time, we tend to choose array lists rather than arrays since we have no idea how big it is going to turn out. Arrays are ideal when you know how many items you are going to put in it. Whenever possible, it is recommended to use arrays as this drastically improves the performance.
Array are sequence of homogeneous data while ArrayList is sequence of heterogenous data. That’s why we have to typecast every data in ArrayLists.
Arrays are multidimensional but ArrayList is always single-dimensional.
Arrays are strongly typed, and work well as parameters. If you know the length of your collection and it is fixed, you should use an array.
ArrayLists are not strongly typed, every Insertion or Retrial will need a cast to get back to your original type. If you need a method to take a list of a specific type, ArrayLists fall short because you could pass in an ArrayList containing any type. ArrayLists use a dynamically expanding array internally, so there is also a hit to expand the size of the internal array when it hits its capacity.