What is the difference between ArrayList and List in VB.NET
ArrayLists are essentially deprecated as they're untyped - you need to use casts with them - and they're slower and less space efficient for value types because they require the items to be boxed.
Generic lists were introduced with .Net 2.0 and are the way to go. Often a List is better than an array, with few downsides.
As these collections are part of the .Net Base Class Library, this advice also applies to C# and to any .Net language which supports generics - it's not specific to VB.NET.
List is a generic implementation of ArrayList. ArrayList stores all objects as System.Object which you need then cast to appropriate type. ArrayLists are heterogenous, List can store only one type of objects - that type supplied as its generic parameter.
List<string> strList; // can store only strings List<int> intList; // can store only ints ArrayList someList; // can store anything
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With