The death of the ArrayList

Jan 25, 2007

In the good old .NET 1.x days where Generics wasn’t born yet, the ArrayList was the class to use for just about any type of collection. It was much easier to use compared to an array of objects and it did the job very well. It was kind of the do-it-all solution for the lazy developer that just needed things to work the first time.

Along came the .NET Framework 2.0 which introduced Generics to the platform. Since the first beta of Visual Studio “Whidbey” was released more than two years ago, I’ve written a couple hundred thousand lines of code in C# 2.0 and not once used an ArrayList. Generic collections like Collection<> and List<> replaced the ArrayList completely from my code and that makes me wonder: Are there still a place for the ArrayList or is it dead?

If it is dead, why hasn’t Microsoft deprecated it with the [obsolete] attribute or at least made a note about it in the documentation? Because Microsoft doesn’t consider it being dead I wonder if I have missed something. Maybe there is a place for it in some obscure scenarios I just haven’t found yet, but I sincerely doubt there is.

So, is the ArrayList dead or not?

* $4.95/month BlogEngine.net Hosting – Click Here!

Comments (3) -

Jason
Jason
1/25/2007 8:46:33 PM #

I'm with you. I have not used ArrayList since moving to 2.0 and haven't looked back.

 ReneMT
ReneMT
1/26/2007 7:25:09 AM #

Maybe they did it to save the several houndred thousands of .NET 1.x developers the need to refactor their code. Just because - as you pointed out - the ArrayList probably was one of the most-used classes in 1.x.

But I agree - I even didn't use it since 2.0 a single time Smile

dave thieben
dave thieben
1/26/2007 2:19:57 PM #

the only use I can see for ArrayList (or, similarly, Hashtable) is if you are storing objects of different types in the array.

it may be said that this is not a good idea, or that there is a better way to implement code that does this, but... there ya go.

i also think its probably in there for backwards compatibility and idiot-proofing.

Comments are closed

About the author

Mads Kristensen

Mads Kristensen
Program Manager at the Microsoft Web Platform team and founder of BlogEngine.NET.

More...

Month List

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.