I know that an ArrayCollection is a wrapper over an Array, but what I wanted to know is when to choose one over the other? Will the over usage of ArrayCollections result in performance?
1 Answer
The main advantage of ArrayCollection is collectionChange event which allows to get advantage of data binding with it.
Some others are:
- Possibility to filter or sort elements of collection without modifying or copying of underlying array.
- Implementation of
ICollectionViewwhich allows to create a cursor and iterate collection with it. - Display of multiple arrays in a datagrid / etc (in this case, arrays are automatically converted to arrayCollections anyway)
If you don't need any of these advantages use simple Array.
3 Comments
J_A_X
It should also be noted that ArrayList is a more simplistic ArrayCollection and is slightly faster. It should also be mentioned that performance is an issue with Collections.
Constantiner
You're right @J_A_X! It hasn't latter two advantages I listed but it can be very useful!
Panzercrisis
For the third point, does that include single multi-dimensional arrays?