Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# is there ever a reason to use ArrayList instead of List<T> anymore?

Tags:

c#

list

arraylist

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?

like image 685
jb. Avatar asked Nov 22 '10 23:11

jb.


2 Answers

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.

like image 132
Yaakov Ellis Avatar answered Oct 13 '22 02:10

Yaakov Ellis


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.

like image 23
Jason Avatar answered Oct 13 '22 01:10

Jason