3

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?

Constantiner
  • 14,231
  • 4
  • 27
  • 34
midhunhk
  • 5,560
  • 7
  • 52
  • 83

1 Answers1

8

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 ICollectionView which 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.

PicoCreator
  • 9,886
  • 7
  • 43
  • 64
Constantiner
  • 14,231
  • 4
  • 27
  • 34
  • It should also be noted that ArrayList is a more simplistic ArrayCollection and is slightly faster. It should also be mentioned that [performance](http://www.jamesward.com/demos/ArrayCollectionPerformance/ArrayCollectionPerformance.html) is an issue with Collections. – J_A_X Jun 10 '11 at 17:21
  • You're right @J_A_X! It hasn't latter two advantages I listed but it can be very useful! – Constantiner Jun 10 '11 at 17:27
  • For the third point, does that include single multi-dimensional arrays? – Panzercrisis Jan 10 '13 at 19:15