First of all, the difference between an array and an array list
Variable of type # 1 Arrays must be instantiated at the same time (at least the size of the array must be initialized), and ArrayList can be declared first.
For example:
int[]array = new array[3];
Or int[] array = {1, 2,3};
Or ArrayList MyList = NewArrayList ();
These are all legal, but directly use int[] array; It's no use.
#2.Array can only store homogeneous objects, while ArrayList can store heterogeneous objects.
Isomorphic objects refer to objects of the same type. If an array declared as int[] can only store plastic data, string[] can only store character data, except for an array declared as object[].
ArrayList can store any different types of data (because it contains boxed Object-type objects, in fact, ArrayList uses "Object[]_ items;;" Such private fields to encapsulate objects)
How to store #3 in a CLR managed pair
Arrays are always stored consecutively, while ArrayList is not always stored consecutively.
#4 Initialization Size
The initialization of array objects must only specify the size, and the created array size is fixed, while the size of ArrayList can be dynamically specified, and its size can be specified at initialization or not, that is to say, the space of the object can be arbitrarily increased.
#5 Array cannot add and delete items at will, while ArrayList can insert and delete items anywhere.
Second, the similarity between array and ArrayList.
# 1 has an index, that is, any item can be obtained and modified directly through the index.
#2 All the objects they created are placed in the managed heap.
#3 can enumerate itself (because everyone has implemented the IEnumerable interface).
note:
In C#2.0, it is recommended that you use the standard version of ArrayList, which is the list in the system. Collection.Generics namespace not only ensures type safety, but also improves the efficiency of object processing because there is no process of packaging and unpacking.