2
\$\begingroup\$

I was reading Which Kind Of Array Or Collection Should I Use?

The document states to use list for the most performance.

"...They are the fastest array in unity. For this reason, built-in arrays are the best choice if you need the fastest performance possible from your code (for example, if you're targeting iPhone)...performs significantly faster than ArrayList."

I am inclined to use list besides performance issues as well because...

But it got me to wonder, since everyone seems to favor to make a degrading statement about ArrayLists, is ArrayLists that horrible? If so why does it even exist? Is it more of trace of supposedly deprecated codes?

\$\endgroup\$
5
\$\begingroup\$

Yes, ArrayLists are slow (relative). ArrayLists were part of the .NET framework before .NET 2.0 was released. .NET 2.0 brought us generics which are better for 'generic' collections. More specifically, ArrayLists' .Add method accepts objects causing boxing, whereas, a List<T> takes a predetermined type.. therefore, increasing performance.

For all practical purposes, the functionality of ArrayList in the current .NET Framework is for backwards compatibility with project using .NET Framework 1.0 / 1.1.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ They are so slow and old that they are not supported anymore for newer platforms, so you won't find them if you try to compile your game to Windows Phone or Windows Store Apps. \$\endgroup\$ – Roberto Mar 10 '14 at 0:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.