- Array is: a datatype, thatcan 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.
- Examples:
- int[ ] myNumbers= new int[5];
- myNumbers[0] = 16;
- ArrayList 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.
- Examples:
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.