The death of the ArrayList

by Mads Kristensen 26. January 2007 05:04

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?

* Only $4.95/month ASP.NET & Windows 2008 + IIS 7 Hosting! FREE SQL Included

Tags:

Random thoughts

Comments

1/26/2007 5:46:33 AM #

Jason

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

Jason |

1/26/2007 4:25:09 PM #

 ReneMT

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

ReneMT |

1/26/2007 11:19:57 PM #

dave thieben

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.

dave thieben |

Comments are closed

About the slave

Mads Kristensen Mads Kristensen
Web developer at ZYB and founder of BlogEngine.NET. More...

LinkedIn ZYB Facebook Last.fm Twitter View Mads Kristensen's profile on Technorati

The Lounge

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008