After a deep thought and looking into the implementation of ArrayList
, personally I really want to say It's obsolete, I have no reason to use this class after 2.0. But since it's not marked as [Obsolete]
, is there any usage that I didn't know, better than using a generic class? If yes, please give an example. Thanks.
EDIT Let's take List<T>
as an example, it provides all functions of ArrayList
, and it's strongly-typed. So when do we need to use ArrayList
? Maybe sometimes it has a better performance? I don't know. I appreciate if you can show me something special of ArrayList
.
I think it should be considered effectively obsolete for new code, but there's no compelling reason to mark it obsolete and create warnings in all code which was written before 2.0 was released.
In my experience, most of the types and members which have been marked obsolete by Microsoft are actively dangerous in some respect, and should really be fixed if you still have a codebase using them. While using
ArrayList
is painful and (at least theoretically) prone to discovering type-related bugs at execution time rather than compile time, the type does its job well enough... often there's really no compelling reason to change existing code. It's the kind of change I'd generally consider when I already happened to be working on an area of code which was usingArrayList
, rather than actively seeking out every usage of it.