What is the difference between ArrayList and List<> in C#?
Is it only that List<> has a type while ArrayList doesn’t?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, pretty much.
List<T>is a generic class. It supports storing values of a specific type without casting to or fromobject(which would have incurred boxing/unboxing overhead whenTis a value type in theArrayListcase).ArrayListsimply storesobjectreferences. As a generic collection,List<T>implements the genericIEnumerable<T>interface and can be used easily in LINQ (without requiring anyCastorOfTypecall).ArrayListbelongs to the days that C# didn’t have generics. It’s deprecated in favor ofList<T>. You shouldn’t useArrayListin new code that targets .NET >= 2.0 unless you have to interface with an old API that uses it.