6

The title pretty much sums it up. Now that we have List<T>'s why would anyone want to use an ArrayList instead? The only reason I can think of is if you are forced to use an old version of .NET before List<T> was implemented?

4
  • I suppose if you wanted to have a list of various, unrelated types. Commented Nov 22, 2010 at 23:12
  • 2
    @John: In which case I'd prefer to use List<object> for the sake of consistency. Commented Nov 22, 2010 at 23:14
  • 2
    Various, unrelated types could go into List<object> Commented Nov 22, 2010 at 23:14
  • possible duplicate of c# When should I use List and when should I use arraylist? Commented Nov 22, 2010 at 23:20

5 Answers 5

8

As you said, if for some reason you are stuck with .Net 1.1 then you don't have a choice.

Your question seems to indicate that there is a choice. So then there is no reason to userArrayList. Anything that ArrayList can do, List<T> can do as well, if not better.

Sign up to request clarification or add additional context in comments.

Comments

4

Short answer, no. ArrayList was from when .NET didn't support generics. List is the more flexible (generic) way to handle lists. In fact, I don't think Silverlight even supports ArrayLists at all.

Comments

1

ArrayList is mostly for backward compatibility. In a project when there is a deadline, you may have the time to convert everything from ArrayList to generic List.

Another reason is that you may be using a library that is written in .NET 1.1. So you may force to use ArrayList in your code, and most likely convert it to a generic List for easy coding.

However, there are some differences and you may want to read this: .NET: ArrayList vs List

Comments

0

You said it yourself: backwards compatibility. There's no use for it any more, but it clearly can't be removed from the BCL as it'd break existing code that for whatever reason must be compiled against .NET 1.1.

Comments

0

The only time I've ever used an ArrayList since .Net 2.0 was for use with the built-in My.Settings feature in vb.net, and I've since learned I probably could have shoehorned a generic list in there.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.