What is the difference between ArrayList
and List<>
in C#?
Is it only that List<>
has a type while ArrayLis
As mentioned in .NET Framework documentation
We don't recommend that you use the
ArrayList
class for new development. Instead, we recommend that you use the genericList
class. TheArrayList
class is designed to hold heterogeneous collections of objects. However, it does not always offer the best performance. Instead, we recommend the following:
- For a heterogeneous collection of objects, use the
List
(in C#) orList(Of Object)
(in Visual Basic) type.- For a homogeneous collection of objects, use the
List
class.
See also Non-generic collections shouldn't be used